Java Code Examples for javax.swing.text.Document#removeDocumentListener()
The following examples show how to use
javax.swing.text.Document#removeDocumentListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LWTextAreaPeer.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 2
Source File: LWTextComponentPeer.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 3
Source File: ResourceStringLoader.java From netbeans with Apache License 2.0 | 6 votes |
@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); } }
Example 4
Source File: LWTextComponentPeer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 5
Source File: LWTextAreaPeer.java From hottub with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 6
Source File: LWTextAreaPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 7
Source File: LWTextAreaPeer.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 8
Source File: LWTextComponentPeer.java From hottub with GNU General Public License v2.0 | 6 votes |
@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(); }
Example 9
Source File: EditHistoryTest.java From netbeans with Apache License 2.0 | 5 votes |
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); } }
Example 10
Source File: DummyEditorPane.java From darklaf with MIT License | 5 votes |
@Override public void setLayout(final LayoutManager mgr) { if (mgr instanceof DocumentListener) { Document doc = getDocument(); if (doc != null) doc.removeDocumentListener((DocumentListener) mgr); } }
Example 11
Source File: XmlMultiViewEditorSupport.java From netbeans with Apache License 2.0 | 5 votes |
/** 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(); }
Example 12
Source File: ElementTreePanel.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 13
Source File: TextViewerWindow.java From LoboBrowser with MIT License | 5 votes |
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); }
Example 14
Source File: EditHistoryTest.java From netbeans with Apache License 2.0 | 5 votes |
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); } }
Example 15
Source File: ElementTreePanel.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 16
Source File: OutputPane.java From netbeans with Apache License 2.0 | 5 votes |
@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(); }
Example 17
Source File: ElementTreePanel.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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); } }
Example 18
Source File: XmlMultiViewEditorSupport.java From netbeans with Apache License 2.0 | 5 votes |
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); } } }
Example 19
Source File: DummyTextComponent.java From darklaf with MIT License | 5 votes |
@Override public void setLayout(final LayoutManager mgr) { if (mgr instanceof DocumentListener) { Document doc = getDocument(); if (doc != null) doc.removeDocumentListener((DocumentListener) mgr); } }
Example 20
Source File: DocumentUtilities.java From netbeans with Apache License 2.0 | 2 votes |
/** * 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); }