javax.swing.text.Document#removeDocumentListener ( )源码实例Demo

下面列出了javax.swing.text.Document#removeDocumentListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-8-source   文件: LWTextAreaPeer.java
@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();
}
 
源代码2 项目: jdk8u_jdk   文件: LWTextComponentPeer.java
@Override
public final void setText(final String text) {
    synchronized (getDelegateLock()) {
        // JTextArea.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.setText() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().setText(text);
        revalidate();
        if (firstChangeSkipped) {
            postEvent(new TextEvent(getTarget(),
                                    TextEvent.TEXT_VALUE_CHANGED));
        }
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
源代码3 项目: netbeans   文件: ResourceStringLoader.java
@Override
public void propertyChange(PropertyChangeEvent evt) {
    FileObject closedFile = null;
    
    if (!EditorCookie.Observable.PROP_DOCUMENT.equals(evt.getPropertyName())) {
        return;
    }
    synchronized (this) {
        Document old = (Document)evt.getOldValue();
        if (old != null && docWL != null) {
            old.removeDocumentListener(docWL);
            docWL = null;
        }
        Document nue = (Document)evt.getNewValue();
        if (nue != null) {
            nue.addDocumentListener(docWL = WeakListeners.document(this, nue));
        } else {
            closedFile = extractFileObject(old);
        }
    }
    if (closedFile != null) {
        invalidate(closedFile);
    }
}
 
源代码4 项目: dragonwell8_jdk   文件: LWTextComponentPeer.java
@Override
public final void setText(final String text) {
    synchronized (getDelegateLock()) {
        // JTextArea.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.setText() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().setText(text);
        revalidate();
        if (firstChangeSkipped) {
            postEvent(new TextEvent(getTarget(),
                                    TextEvent.TEXT_VALUE_CHANGED));
        }
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
源代码5 项目: hottub   文件: LWTextAreaPeer.java
@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);
        getTextComponent().replaceRange(text, start, end);
        revalidate();
        postEvent(new TextEvent(getTarget(), TextEvent.TEXT_VALUE_CHANGED));
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
源代码6 项目: jdk8u-jdk   文件: LWTextAreaPeer.java
@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();
}
 
源代码7 项目: hottub   文件: LWTextComponentPeer.java
@Override
public final void setText(final String text) {
    synchronized (getDelegateLock()) {
        // JTextArea.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.setText() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().setText(text);
        revalidate();
        if (firstChangeSkipped) {
            postEvent(new TextEvent(getTarget(),
                                    TextEvent.TEXT_VALUE_CHANGED));
        }
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
源代码8 项目: openjdk-8   文件: LWTextAreaPeer.java
@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();
}
 
源代码9 项目: darklaf   文件: DummyEditorPane.java
@Override
public void setLayout(final LayoutManager mgr) {
    if (mgr instanceof DocumentListener) {
        Document doc = getDocument();
        if (doc != null) doc.removeDocumentListener((DocumentListener) mgr);
    }
}
 
源代码10 项目: darklaf   文件: DummyTextComponent.java
@Override
public void setLayout(final LayoutManager mgr) {
    if (mgr instanceof DocumentListener) {
        Document doc = getDocument();
        if (doc != null) doc.removeDocumentListener((DocumentListener) mgr);
    }
}
 
源代码11 项目: netbeans   文件: XmlMultiViewEditorSupport.java
public void run() {
    Document document = getDocument();
    DocumentListener listener = document == null ? null :
        (DocumentListener) document.getProperty(PROPERTY_MODIFICATION_LISTENER);
    if (listener != null) {
        document.removeDocumentListener(listener);
    }
    try {
        reloadModel();
    } finally {
        if (listener != null) {
            document.addDocumentListener(listener);
        }
    }
}
 
源代码12 项目: TencentKona-8   文件: ElementTreePanel.java
/**
 * Resets the JTextComponent to <code>editor</code>. This will update
 * the tree accordingly.
 */
public void setEditor(JTextComponent editor) {
    if (this.editor == editor) {
        return;
    }

    if (this.editor != null) {
        Document oldDoc = this.editor.getDocument();

        oldDoc.removeDocumentListener(this);
        this.editor.removePropertyChangeListener(this);
        this.editor.removeCaretListener(this);
    }
    this.editor = editor;
    if (editor == null) {
        treeModel = null;
        tree.setModel(null);
    } else {
        Document newDoc = editor.getDocument();

        newDoc.addDocumentListener(this);
        editor.addPropertyChangeListener(this);
        editor.addCaretListener(this);
        treeModel = new ElementTreeModel(newDoc);
        tree.setModel(treeModel);
    }
}
 
源代码13 项目: netbeans   文件: OutputPane.java
@Override
protected void setDocument (Document doc) {
    if (doc == null) {
        Document d = getDocument();
        if (d != null) {
            d.removeDocumentListener(this);
        }
        textView.setDocument (new PlainDocument());
        return;
    }
    textView.setEditorKit(new OutputEditorKit(isWrapped(), textView,
            editorKitListener));
    super.setDocument(doc);
    updateKeyBindings();
}
 
源代码14 项目: openjdk-jdk9   文件: ElementTreePanel.java
/**
 * Resets the JTextComponent to <code>editor</code>. This will update
 * the tree accordingly.
 */
public void setEditor(JTextComponent editor) {
    if (this.editor == editor) {
        return;
    }

    if (this.editor != null) {
        Document oldDoc = this.editor.getDocument();

        oldDoc.removeDocumentListener(this);
        this.editor.removePropertyChangeListener(this);
        this.editor.removeCaretListener(this);
    }
    this.editor = editor;
    if (editor == null) {
        treeModel = null;
        tree.setModel(null);
    } else {
        Document newDoc = editor.getDocument();

        newDoc.addDocumentListener(this);
        editor.addPropertyChangeListener(this);
        editor.addCaretListener(this);
        treeModel = new ElementTreeModel(newDoc);
        tree.setModel(treeModel);
    }
}
 
源代码15 项目: netbeans   文件: EditHistoryTest.java
private void remove(Document document, EditHistory history, int offset, int length) throws Exception {
    try {
        document.addDocumentListener(history);
        document.remove(offset, length);
    } finally {
        document.removeDocumentListener(history);
    }
}
 
源代码16 项目: LoboBrowser   文件: TextViewerWindow.java
public void setSwingDocument(final Document document) {
  final Document prevDocument = this.textArea.getDocument();
  final DocumentListener listener = this.getDocumentListener();
  if (prevDocument != null) {
    prevDocument.removeDocumentListener(listener);
  }
  document.addDocumentListener(listener);
  this.textArea.setDocument(document);
}
 
源代码17 项目: openjdk-jdk8u   文件: ElementTreePanel.java
/**
 * Resets the JTextComponent to <code>editor</code>. This will update
 * the tree accordingly.
 */
public void setEditor(JTextComponent editor) {
    if (this.editor == editor) {
        return;
    }

    if (this.editor != null) {
        Document oldDoc = this.editor.getDocument();

        oldDoc.removeDocumentListener(this);
        this.editor.removePropertyChangeListener(this);
        this.editor.removeCaretListener(this);
    }
    this.editor = editor;
    if (editor == null) {
        treeModel = null;
        tree.setModel(null);
    } else {
        Document newDoc = editor.getDocument();

        newDoc.addDocumentListener(this);
        editor.addPropertyChangeListener(this);
        editor.addCaretListener(this);
        treeModel = new ElementTreeModel(newDoc);
        tree.setModel(treeModel);
    }
}
 
源代码18 项目: netbeans   文件: XmlMultiViewEditorSupport.java
/** Resolving problems when editor was modified and closed
 * (issue 57483)
 */
protected void notifyClosed() {
    mvtc = null;
    if (topComponentsListener != null) {
        TopComponent.getRegistry().removePropertyChangeListener(topComponentsListener);
        topComponentsListener = null;
    }
    Document document = getDocument();
    if (document!=null) document.removeDocumentListener(docListener);
    super.notifyClosed();
}
 
源代码19 项目: netbeans   文件: EditHistoryTest.java
private void insert(Document document, EditHistory history, int offset, String string) throws Exception {
    try {
        document.addDocumentListener(history);
        document.insertString(offset, string, null);
    } finally {
        document.removeDocumentListener(history);
    }
}
 
源代码20 项目: netbeans   文件: DocumentUtilities.java
/**
 * Remove document listener that was previously added to the document
 * with given priority or use default {@link Document#removeDocumentListener(DocumentListener)}
 * if the given document is not listener priority aware.
 * 
 * @param doc document from which the listener should be removed.
 * @param listener document listener to remove.
 * @param priority priority with which the listener should be removed.
 *  It should correspond to the priority with which the listener
 *  was added originally.
 */
public static void removeDocumentListener(Document doc, DocumentListener listener,
DocumentListenerPriority priority) {
    if (!removePriorityDocumentListener(doc, listener, priority))
        doc.removeDocumentListener(listener);
}