APIdia Launch Partner
Top Description Inners Methods
javax.swing.event

public Interface DocumentEvent

Known Direct Implementers
javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.UndoRedoDocumentEvent
Imports
javax.swing.text.Document, .Element

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).
Author
Timothy Prinzing
See Also
javax.swing.text.Document, DocumentListener

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
DocumentEvent.ElementChange

Describes changes made to a specific element.

public static class
DocumentEvent.EventType

Enumeration for document event types

Method Summary

Modifier and TypeMethod and Description
public DocumentEvent.ElementChange

Returns:

the change information, or null if the element was not modified
getChange
(Element
the element
elem
)

Gets the change information for the given element.

public Document

Returns:

the document
getDocument
()

Gets the document that sourced the change event.

public int

Returns:

the length >= 0
getLength
()

Returns the length of the change.

public int

Returns:

the offset >= 0
getOffset
()

Returns the offset within the document of the start of the change.

public DocumentEvent.EventType

Returns:

the type
getType
()

Gets the type of event.

Method Detail

getChangeback to summary
public DocumentEvent.ElementChange getChange(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 mutation) need to have ElementChange records. The changes made available need not be recursive.

For example, if an element is removed from its 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 a child element is inserted 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:Element

the element

Returns:DocumentEvent.ElementChange

the change information, or null if the element was not modified

getDocumentback to summary
public Document getDocument()

Gets the document that sourced the change event.

Returns:Document

the document

getLengthback to summary
public int getLength()

Returns the length of the change.

Returns:int

the length >= 0

getOffsetback to summary
public int getOffset()

Returns the offset within the document of the start of the change.

Returns:int

the offset >= 0

getTypeback to summary
public DocumentEvent.EventType getType()

Gets the type of event.

Returns:DocumentEvent.EventType

the type

javax.swing.event back to summary

public Interface DocumentEvent.ElementChange

Known Direct Implementers
javax.swing.text.AbstractDocument.ElementEdit

Describes changes made to a specific element.

Method Summary

Modifier and TypeMethod and Description
public Element[]

Returns:

the child elements
getChildrenAdded
()

Gets the child elements that were added to the given parent element.

public Element[]

Returns:

the child elements
getChildrenRemoved
()

Gets the child elements that were removed from the given parent element.

public Element

Returns:

the element
getElement
()

Returns the element represented.

public int

Returns:

the index >= 0
getIndex
()

Fetches the index within the element represented.

Method Detail

getChildrenAddedback to summary
public Element[] getChildrenAdded()

Gets the child elements that were added to the given parent element. The element array returned is in the order that the elements lie in the document, and must be contiguous.

Returns:Element[]

the child elements

getChildrenRemovedback to summary
public Element[] getChildrenRemoved()

Gets the child elements that were removed from the given parent element. The element array returned is sorted in the order that the elements used to lie in the document, and must be contiguous.

Returns:Element[]

the child elements

getElementback to summary
public Element getElement()

Returns the element represented. This is the element that was changed.

Returns:Element

the element

getIndexback to summary
public int getIndex()

Fetches the index within the element represented. This is the location that children were added and/or removed.

Returns:int

the index >= 0

javax.swing.event back to summary

public final Class DocumentEvent.EventType

extends Object
Class Inheritance

Enumeration for document event types

Field Summary

Modifier and TypeField and Description
public static final DocumentEvent.EventType
CHANGE

Change type.

public static final DocumentEvent.EventType
INSERT

Insert type.

public static final DocumentEvent.EventType
REMOVE

Remove type.

private String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the string
toString
()

Overrides java.lang.Object.toString.

Converts the type to a string.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

CHANGEback to summary
public static final DocumentEvent.EventType CHANGE

Change type.

INSERTback to summary
public static final DocumentEvent.EventType INSERT

Insert type.

REMOVEback to summary
public static final DocumentEvent.EventType REMOVE

Remove type.

typeStringback to summary
private String typeString

Constructor Detail

EventTypeback to summary
private EventType(String s)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Converts the type to a string.

Returns:String

the string