Spec-Zone.ru › OpenJDK 25

Interface DocumentListener

All Superinterfaces:
EventListener
All Known Implementing Classes:
JEditorPane.AccessibleJEditorPane, JEditorPane.AccessibleJEditorPaneHTML, JEditorPane.JEditorPaneAccessibleHypertextSupport, JPasswordField.AccessibleJPasswordField, JTextArea.AccessibleJTextArea, JTextComponent.AccessibleJTextComponent, JTextField.AccessibleJTextField
public interface DocumentListener extends EventListener
Interface for an observer to register to receive notifications of changes to a text document.

The default implementation of the Document interface (AbstractDocument) supports asynchronous mutations. If this feature is used (i.e. mutations are made from a thread other than the Swing event thread), the listeners will be notified via the mutating thread. This means that if asynchronous updates are made, the implementation of this interface must be threadsafe!

The DocumentEvent notification is based upon the JavaBeans event model. There is no guarantee about the order of delivery to listeners, and all listeners must be notified prior to making further mutations to the Document. This means implementations of the DocumentListener may not mutate the source of the event (i.e. the associated Document).

See Also:
  • Document
  • StyledDocument
  • DocumentEvent

Method Summary

Modifier and Type Method Description
void changedUpdate(DocumentEvent e)
Gives notification that an attribute or set of attributes changed.
void insertUpdate(DocumentEvent e)
Gives notification that there was an insert into the document.
void removeUpdate(DocumentEvent e)
Gives notification that a portion of the document has been removed.

Method Details

insertUpdate

void insertUpdate(DocumentEvent e)
Gives notification that there was an insert into the document. The range given by the DocumentEvent bounds the freshly inserted region.
Parameters:
e - the document event

removeUpdate

void removeUpdate(DocumentEvent e)
Gives notification that a portion of the document has been removed. The range is given in terms of what the view last saw (that is, before updating sticky positions).
Parameters:
e - the document event

changedUpdate

void changedUpdate(DocumentEvent e)
Gives notification that an attribute or set of attributes changed.
Parameters:
e - the document event

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2025, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.desktop/javax/swing/event/DocumentListener.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API