/** Used to reset the contents of this document */ public void clear() { try { super.remove(0, getLength()); setMark(); } catch (BadLocationException e) { } }
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()); } }
@Override public void remove(int offs, int len) throws BadLocationException { int start = offs; int end = offs + len; int markStart = mark; int markEnd = getLength(); if ((end < markStart) || (start > markEnd)) { // no overlap return; } // Determine interval intersection int cutStart = Math.max(start, markStart); int cutEnd = Math.min(end, markEnd); super.remove(cutStart, cutEnd - cutStart); }
public void insertString(int ii, String s, AttributeSet attributeset) throws BadLocationException { if (s == null || "".equals(s)) return; String base = getText(0, ii); String match = getMatch(base + s); if (match == null) { super.insertString(ii, s, attributeset); return; } int jj = ii + s.length(); super.remove(0, getLength()); super.insertString(0, base + s + match.substring(jj), attributeset); setSelectionStart(jj); setSelectionEnd(getLength()); }
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); } }
public void forceRemove(int offset, int len) throws BadLocationException { super.remove(offset, len); }
public void replace(int i, int j, String s, AttributeSet attributeset) throws BadLocationException { super.remove(i, j); insertString(i, s, attributeset); }
@Override public void remove(final int offs, final int len) throws BadLocationException { checked = false; super.remove(offs, len); }