Java Code Examples for javax.swing.text.Document#removeDocumentListener()
The following examples show how to use
javax.swing.text.Document#removeDocumentListener() .
These examples are extracted from open source projects.
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 Project: openjdk-8-source File: LWTextAreaPeer.java License: 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 Project: jdk8u_jdk File: LWTextComponentPeer.java License: 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 Project: netbeans File: ResourceStringLoader.java License: 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 Project: dragonwell8_jdk File: LWTextComponentPeer.java License: 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 Project: hottub File: LWTextAreaPeer.java License: 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 Project: jdk8u-jdk File: LWTextAreaPeer.java License: 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 Project: hottub File: LWTextComponentPeer.java License: 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 8
Source Project: openjdk-8 File: LWTextAreaPeer.java License: 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 9
Source Project: darklaf File: DummyEditorPane.java License: 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 10
Source Project: darklaf File: DummyTextComponent.java License: 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 Project: netbeans File: XmlMultiViewEditorSupport.java License: 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 12
Source Project: TencentKona-8 File: ElementTreePanel.java License: 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 Project: netbeans File: OutputPane.java License: 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 14
Source Project: openjdk-jdk9 File: ElementTreePanel.java License: 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 15
Source Project: netbeans File: EditHistoryTest.java License: 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 16
Source Project: LoboBrowser File: TextViewerWindow.java License: 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 17
Source Project: openjdk-jdk8u File: ElementTreePanel.java License: 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 Project: netbeans File: XmlMultiViewEditorSupport.java License: 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 19
Source Project: netbeans File: EditHistoryTest.java License: 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 20
Source Project: netbeans File: DocumentUtilities.java License: 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); }