Lukasz Robert Pawlowski of Pembroke Dock, appeared for sentence at the Pembrokeshire court on Wednesday after pleading guilty to sexual assault.
He was airlifted to Swansea's Morriston Hospital and is said to be recovering.
Dyfed-Powys Police confirmed they have arrested a 33-year-old man on suspicion of possession of an article with a blade or point.
It is understood he lost consciousness and bled heavily after cutting himself.
The court was closed after the incident but reopened on Thursday.

Michael Higdon scored what proved to be the decisive goal, heading home Lee Vaughan's cross just before the hour.
Torquay almost grabbed a late equaliser when Luke Young's 25-yard free-kick was saved by Scott Davies, but Rovers held onto the lead to move three points clear in the final play-off position.
The Gulls remain in 18th with a three-point cushion from the division's relegation places.

Jim Shaw suffered broken ribs when the footbridge near Maidstone was hit by a lorry carrying a digger on Saturday.
The 73-year-old was travelling at 70mph towards London when "chaos broke loose" and "bits were flying everywhere".
"I moved to the outside lane. There was only one place to go. I threw the bike on the floor and went under," he said.
Mr Shaw's bike was trapped under tonnes of concrete following the collapse.
Part of the bridge also fell on to a second lorry, the driver of which was treated for shock at the scene.
Speaking from his hospital bed in Tunbridge Wells, Mr Shaw said he had been "riding down the motorway, enjoying life as it goes by" on his bike when he was forced to take evasive action.
Describing what unfolded, he said "the bridge was coming down, almost like in slow motion, because it's eating its way through the lorry".
"But then it tore away from the other side. As that came down, it was a matter of throw the bike on the floor and go for it."
"I've a few broken ribs, but they mend," he said.
The bridge, between junctions three and four, came down on the London-bound carriageway just after 12:05 BST.
The M20 had to be closed in both directions as two large cranes worked to clear the road, which is the main route to the Channel Tunnel and Port of Dover.
It fully re-opened on Sunday, with the remaining part of the footbridge still hanging over the coast-bound side.
Officials have said the structure is safe and an operation to remove it will take place in the coming weeks.
No-one has been arrested in connection with the incident.
A sex attacker who cut his own throat in the dock at Haverfordwest Magistrates' Court has been arrested.
[NEXT_CONCEPT]
Tranmere consolidated their play-off position with a narrow win at Torquay.
[NEXT_CONCEPT]
A motorcyclist who was injured when a pedestrian bridge collapsed on to the M20 has described how he threw himself off his bike to avoid the impact.