javax.swing.event
Interface DocumentListener

All Superinterfaces:
EventListener sample code for java.util.EventListener definition code for java.util.EventListener
All Known Implementing Classes:
JEditorPane.AccessibleJEditorPane sample code for javax.swing.JEditorPane.AccessibleJEditorPane definition code for javax.swing.JEditorPane.AccessibleJEditorPane , JEditorPane.AccessibleJEditorPaneHTML sample code for javax.swing.JEditorPane.AccessibleJEditorPaneHTML definition code for javax.swing.JEditorPane.AccessibleJEditorPaneHTML , JEditorPane.JEditorPaneAccessibleHypertextSupport sample code for javax.swing.JEditorPane.JEditorPaneAccessibleHypertextSupport definition code for javax.swing.JEditorPane.JEditorPaneAccessibleHypertextSupport , JPasswordField.AccessibleJPasswordField sample code for javax.swing.JPasswordField.AccessibleJPasswordField definition code for javax.swing.JPasswordField.AccessibleJPasswordField , JTextArea.AccessibleJTextArea sample code for javax.swing.JTextArea.AccessibleJTextArea definition code for javax.swing.JTextArea.AccessibleJTextArea , JTextComponent.AccessibleJTextComponent sample code for javax.swing.text.JTextComponent.AccessibleJTextComponent definition code for javax.swing.text.JTextComponent.AccessibleJTextComponent , JTextField.AccessibleJTextField sample code for javax.swing.JTextField.AccessibleJTextField definition code for javax.swing.JTextField.AccessibleJTextField

public interface DocumentListener
extends EventListener sample code for java.util.EventListener definition code for java.util.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 sample code for javax.swing.text.Document definition code for javax.swing.text.Document , StyledDocument sample code for javax.swing.text.StyledDocument definition code for javax.swing.text.StyledDocument , DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent

Method Summary
 void changedUpdate sample code for javax.swing.event.DocumentListener.changedUpdate(javax.swing.event.DocumentEvent) definition code for javax.swing.event.DocumentListener.changedUpdate(javax.swing.event.DocumentEvent) (DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent  e)
          Gives notification that an attribute or set of attributes changed.
 void insertUpdate sample code for javax.swing.event.DocumentListener.insertUpdate(javax.swing.event.DocumentEvent) definition code for javax.swing.event.DocumentListener.insertUpdate(javax.swing.event.DocumentEvent) (DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent  e)
          Gives notification that there was an insert into the document.
 void removeUpdate sample code for javax.swing.event.DocumentListener.removeUpdate(javax.swing.event.DocumentEvent) definition code for javax.swing.event.DocumentListener.removeUpdate(javax.swing.event.DocumentEvent) (DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent  e)
          Gives notification that a portion of the document has been removed.
 

Method Detail

insertUpdate sample code for javax.swing.event.DocumentListener.insertUpdate(javax.swing.event.DocumentEvent) definition code for javax.swing.event.DocumentListener.insertUpdate(javax.swing.event.DocumentEvent)

void insertUpdate(DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.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 sample code for javax.swing.event.DocumentListener.removeUpdate(javax.swing.event.DocumentEvent) definition code for javax.swing.event.DocumentListener.removeUpdate(javax.swing.event.DocumentEvent)

void removeUpdate(DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.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 sample code for javax.swing.event.DocumentListener.changedUpdate(javax.swing.event.DocumentEvent) definition code for javax.swing.event.DocumentListener.changedUpdate(javax.swing.event.DocumentEvent)

void changedUpdate(DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent  e)
Gives notification that an attribute or set of attributes changed.

Parameters:
e - the document event