AttributedCharacterIterator (AttributedCharacterIterator.Attribute[] attributes) { if (myCharKeyPressed) { myNeedToSelectPreviousChar = true; } String text = getSelectionModel().getSelectedText(); return text == null ? null : new AttributedString(text).getIterator(); }