javax.swing.event
Interface DocumentEvent

All Known Implementing Classes:
AbstractDocument.DefaultDocumentEvent sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent

public interface DocumentEvent

Interface for document change notifications. This provides detailed information to Document observers about how the Document changed. It provides high level information such as type of change and where it occurred, as well as the more detailed structural changes (What Elements were inserted and removed).

See Also:
Document sample code for javax.swing.text.Document definition code for javax.swing.text.Document , DocumentListener sample code for javax.swing.event.DocumentListener definition code for javax.swing.event.DocumentListener

Nested Class Summary
static interface DocumentEvent.ElementChange sample code for javax.swing.event.DocumentEvent.ElementChange definition code for javax.swing.event.DocumentEvent.ElementChange
          Describes changes made to a specific element.
static class DocumentEvent.EventType sample code for javax.swing.event.DocumentEvent.EventType definition code for javax.swing.event.DocumentEvent.EventType
          Enumeration for document event types
 
Method Summary
 DocumentEvent.ElementChange sample code for javax.swing.event.DocumentEvent.ElementChange definition code for javax.swing.event.DocumentEvent.ElementChange getChange sample code for javax.swing.event.DocumentEvent.getChange(javax.swing.text.Element) definition code for javax.swing.event.DocumentEvent.getChange(javax.swing.text.Element) (Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem)
          Gets the change information for the given element.
 Document sample code for javax.swing.text.Document definition code for javax.swing.text.Document getDocument sample code for javax.swing.event.DocumentEvent.getDocument() definition code for javax.swing.event.DocumentEvent.getDocument() ()
          Gets the document that sourced the change event.
 int getLength sample code for javax.swing.event.DocumentEvent.getLength() definition code for javax.swing.event.DocumentEvent.getLength() ()
          Returns the length of the change.
 int getOffset sample code for javax.swing.event.DocumentEvent.getOffset() definition code for javax.swing.event.DocumentEvent.getOffset() ()
          Returns the offset within the document of the start of the change.
 DocumentEvent.EventType sample code for javax.swing.event.DocumentEvent.EventType definition code for javax.swing.event.DocumentEvent.EventType getType sample code for javax.swing.event.DocumentEvent.getType() definition code for javax.swing.event.DocumentEvent.getType() ()
          Gets the type of event.
 

Method Detail

getOffset sample code for javax.swing.event.DocumentEvent.getOffset() definition code for javax.swing.event.DocumentEvent.getOffset()

int getOffset()
Returns the offset within the document of the start of the change.

Returns:
the offset >= 0

getLength sample code for javax.swing.event.DocumentEvent.getLength() definition code for javax.swing.event.DocumentEvent.getLength()

int getLength()
Returns the length of the change.

Returns:
the length >= 0

getDocument sample code for javax.swing.event.DocumentEvent.getDocument() definition code for javax.swing.event.DocumentEvent.getDocument()

Document sample code for javax.swing.text.Document definition code for javax.swing.text.Document  getDocument()
Gets the document that sourced the change event.

Returns:
the document

getType sample code for javax.swing.event.DocumentEvent.getType() definition code for javax.swing.event.DocumentEvent.getType()

DocumentEvent.EventType sample code for javax.swing.event.DocumentEvent.EventType definition code for javax.swing.event.DocumentEvent.EventType  getType()
Gets the type of event.

Returns:
the type

getChange sample code for javax.swing.event.DocumentEvent.getChange(javax.swing.text.Element) definition code for javax.swing.event.DocumentEvent.getChange(javax.swing.text.Element)

DocumentEvent.ElementChange sample code for javax.swing.event.DocumentEvent.ElementChange definition code for javax.swing.event.DocumentEvent.ElementChange  getChange(Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem)
Gets the change information for the given element. The change information describes what elements were added and removed and the location. If there were no changes, null is returned.

This method is for observers to discover the structural changes that were made. This means that only elements that existed prior to the mutation (and still exist after the mutatino) need to have ElementChange records. The changes made available need not be recursive.

For example, if the an element is removed from it's parent, this method should report that the parent changed and provide an ElementChange implementation that describes the change to the parent. If the child element removed had children, these elements do not need to be reported as removed.

If an child element is insert into a parent element, the parent element should report a change. If the child element also had elements inserted into it (grandchildren to the parent) these elements need not report change.

Parameters:
elem - the element
Returns:
the change information, or null if the element was not modified