posted 17 years ago
don't know that there's a non-ugly way to do this.
A keylistener checking isShiftDown() and resetting selectionStart/end to the
caret position seems to work OK, but the code sure is ugly.
if you're already using a document to replace/insert a single character,
perhaps it might be easier to allow the multi-character selection, then check if(textfield.getSelectedText().length() == 1) (check for null first)
or, if using a DocumentFilter, the length argument, then proceeding if true.