public class

AbstractDocument.DefaultDocumentEvent

extends CompoundEdit
implements DocumentEvent
java.lang.Object
   ↳ javax.swing.undo.AbstractUndoableEdit
     ↳ javax.swing.undo.CompoundEdit
       ↳ javax.swing.text.AbstractDocument.DefaultDocumentEvent

Class Overview

Stores document changes as the document is being modified. Can subsequently be used for change notification when done with the document modification transaction. This is used by the AbstractDocument class and its extensions for broadcasting change information to the document listeners.

Summary

[Expand]
Inherited Constants
From class javax.swing.undo.AbstractUndoableEdit
[Expand]
Inherited Fields
From class javax.swing.undo.CompoundEdit
Public Constructors
AbstractDocument.DefaultDocumentEvent(int offs, int len, DocumentEvent.EventType type)
Constructs a change record.
Public Methods
boolean addEdit(UndoableEdit anEdit)
Adds a document edit.
DocumentEvent.ElementChange getChange(Element elem)
Gets the changes for an element.
Document getDocument()
Gets the document that sourced the change event.
int getLength()
Returns the length of the change.
int getOffset()
Returns the offset within the document of the start of the change.
String getPresentationName()
Provides a localized, human readable description of this edit suitable for use in, say, a change log.
String getRedoPresentationName()
Provides a localized, human readable description of the redoable form of this edit, e.g.
DocumentEvent.EventType getType()
Returns the type of event.
String getUndoPresentationName()
Provides a localized, human readable description of the undoable form of this edit, e.g.
boolean isSignificant()
DefaultDocument events are significant.
void redo()
Redoes a change.
String toString()
Returns a string description of the change event.
void undo()
Undoes a change.
[Expand]
Inherited Methods
From class javax.swing.undo.CompoundEdit
From class javax.swing.undo.AbstractUndoableEdit
From class java.lang.Object
From interface javax.swing.event.DocumentEvent
From interface javax.swing.undo.UndoableEdit

Public Constructors

public AbstractDocument.DefaultDocumentEvent (int offs, int len, DocumentEvent.EventType type)

Constructs a change record.

Parameters
offs the offset into the document of the change >= 0
len the length of the change >= 0
type the type of event (DocumentEvent.EventType)

Public Methods

public boolean addEdit (UndoableEdit anEdit)

Adds a document edit. If the number of edits crosses a threshold, this switches on a hashtable lookup for ElementChange implementations since access of these needs to be relatively quick.

Parameters
anEdit a document edit record
Returns
  • true if the edit was added

public DocumentEvent.ElementChange getChange (Element elem)

Gets the changes for an element.

Parameters
elem the element
Returns
  • the changes

public Document getDocument ()

Gets the document that sourced the change event.

Returns
  • the document
See Also

public int getLength ()

Returns the length of the change.

Returns
  • the length >= 0
See Also

public int getOffset ()

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

Returns
  • the offset >= 0
See Also

public String getPresentationName ()

Provides a localized, human readable description of this edit suitable for use in, say, a change log.

Returns
  • the description

public String getRedoPresentationName ()

Provides a localized, human readable description of the redoable form of this edit, e.g. for use as a Redo menu item. Typically derived from getPresentationName();

Returns
  • the description

public DocumentEvent.EventType getType ()

Returns the type of event.

Returns
  • the event type as a DocumentEvent.EventType
See Also

public String getUndoPresentationName ()

Provides a localized, human readable description of the undoable form of this edit, e.g. for use as an Undo menu item. Typically derived from getDescription();

Returns
  • the description

public boolean isSignificant ()

DefaultDocument events are significant. If you wish to aggregate DefaultDocumentEvents to present them as a single edit to the user place them into a CompoundEdit.

Returns
  • whether the event is significant for edit undo purposes

public void redo ()

Redoes a change.

Throws
CannotRedoException if the change cannot be redone

public String toString ()

Returns a string description of the change event.

Returns
  • a string

public void undo ()

Undoes a change.

Throws
CannotUndoException if the change cannot be undone