Bounds leadingSelectionBounds = getCharacterBounds(selectionStart);
// sanity check - this is where a lot of bugs show up
if (leadingSelectionBounds == null) {
throw new IllegalStateException("no bounds for selection " + selectionStart);
}
caret = leadingSelectionBounds.toRectangle();
caret.width = 1;
// Update the selection
int selectionLength = textPane.getSelectionLength();