private void setText(String text) { try { // remove all text and insert the completed string super.remove(0, getLength()); super.insertString(0, text, null); } catch (BadLocationException e) { throw new RuntimeException(e.toString()); } }
public void remove(int offs, int len) throws BadLocationException { // return immediately when selecting an item if (selecting) { return; } if (hitBackspace) { // user hit backspace => move the selection backwards // old item keeps being selected if (offs > 0) { if (hitBackspaceOnSelection) { offs--; } } else { // User hit backspace with the cursor positioned on the start => beep comboBox.getToolkit().beep(); // when available use: // UIManager.getLookAndFeel().provideErrorFeedback(comboBox); } highlightCompletedText(offs); } else { super.remove(offs, len); } }
@Override public void remove(final int offs, final int len) throws BadLocationException { checked = false; super.remove(offs, len); }