/* * To prevent memory from being used up you can control the number of * lines to display in the console * * This number can be dynamically changed, but the console will only * be updated the next time the Document is updated. */ public void setMessageLines(final int lines) { if (limitLinesListener != null) { document.removeDocumentListener(limitLinesListener); } limitLinesListener = new LimitLinesDocumentListener(lines, isAppend); document.addDocumentListener(limitLinesListener); }
@Override public void replaceRange(final String text, final int start, final int end) { synchronized (getDelegateLock()) { // JTextArea.replaceRange() posts two different events. // Since we make no differences between text events, // the document listener has to be disabled while // JTextArea.replaceRange() is called. final Document document = getTextComponent().getDocument(); document.removeDocumentListener(this); getDelegate().getView().replaceRange(text, start, end); revalidate(); postEvent(new TextEvent(getTarget(), TextEvent.TEXT_VALUE_CHANGED)); document.addDocumentListener(this); } repaintPeer(); }
public void propertyChange(PropertyChangeEvent evt) { String prop = evt.getPropertyName(); Object src = evt.getSource(); if (src.equals(searchField)) { if ("findPopupMenu".equals(prop) || "searchMode".equals(prop) || "useSeperatePopupButton".equals(prop) || "searchMode".equals(prop) || "layoutStyle".equals(prop)) { layoutButtons(); updateButtons(); } else if ("document".equals(prop)) { Document doc = (Document) evt.getOldValue(); if (doc != null) { doc.removeDocumentListener(this); } doc = (Document) evt.getNewValue(); if (doc != null) { doc.addDocumentListener(this); } } } }
/** Cleans up. */ public void finish() { document.removeDocumentListener(documentListener); }
/** * Notify this {@link LineID} that it is no longer in use. Will stop position tracking. Call this * when this {@link LineID} is no longer needed. */ public synchronized void stopTracking() { if (doc != null) { doc.removeDocumentListener(this); doc = null; } }