javax.swing.text
Class AbstractDocument.DefaultDocumentEvent

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.swing.undo.AbstractUndoableEdit sample code for javax.swing.undo.AbstractUndoableEdit definition code for javax.swing.undo.AbstractUndoableEdit 
      extended by javax.swing.undo.CompoundEdit sample code for javax.swing.undo.CompoundEdit definition code for javax.swing.undo.CompoundEdit 
          extended by javax.swing.text.AbstractDocument.DefaultDocumentEvent
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent , UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit
Enclosing class:
AbstractDocument sample code for javax.swing.text.AbstractDocument definition code for javax.swing.text.AbstractDocument

public class AbstractDocument.DefaultDocumentEvent
extends CompoundEdit sample code for javax.swing.undo.CompoundEdit definition code for javax.swing.undo.CompoundEdit
implements DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent

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.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.swing.event.DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent
DocumentEvent.ElementChange sample code for javax.swing.event.DocumentEvent.ElementChange definition code for javax.swing.event.DocumentEvent.ElementChange , DocumentEvent.EventType sample code for javax.swing.event.DocumentEvent.EventType definition code for javax.swing.event.DocumentEvent.EventType
 
Field Summary
 
Fields inherited from class javax.swing.undo.CompoundEdit sample code for javax.swing.undo.CompoundEdit definition code for javax.swing.undo.CompoundEdit
edits sample code for javax.swing.undo.CompoundEdit.edits definition code for javax.swing.undo.CompoundEdit.edits
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit sample code for javax.swing.undo.AbstractUndoableEdit definition code for javax.swing.undo.AbstractUndoableEdit
RedoName sample code for javax.swing.undo.AbstractUndoableEdit.RedoName definition code for javax.swing.undo.AbstractUndoableEdit.RedoName , UndoName sample code for javax.swing.undo.AbstractUndoableEdit.UndoName definition code for javax.swing.undo.AbstractUndoableEdit.UndoName
 
Constructor Summary
AbstractDocument.DefaultDocumentEvent sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.AbstractDocument.DefaultDocumentEvent(int, int, javax.swing.event.DocumentEvent.EventType) definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.AbstractDocument.DefaultDocumentEvent(int, int, javax.swing.event.DocumentEvent.EventType) (int offs, int len, DocumentEvent.EventType sample code for javax.swing.event.DocumentEvent.EventType definition code for javax.swing.event.DocumentEvent.EventType  type)
          Constructs a change record.
 
Method Summary
 boolean addEdit sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.addEdit(javax.swing.undo.UndoableEdit) definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.addEdit(javax.swing.undo.UndoableEdit) (UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit  anEdit)
          Adds a document edit.
 DocumentEvent.ElementChange sample code for javax.swing.event.DocumentEvent.ElementChange definition code for javax.swing.event.DocumentEvent.ElementChange getChange sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getChange(javax.swing.text.Element) definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getChange(javax.swing.text.Element) (Element sample code for javax.swing.text.Element definition code for javax.swing.text.Element  elem)
          Gets the changes for an element.
 Document sample code for javax.swing.text.Document definition code for javax.swing.text.Document getDocument sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getDocument() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getDocument() ()
          Gets the document that sourced the change event.
 int getLength sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getLength() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getLength() ()
          Returns the length of the change.
 int getOffset sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getOffset() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getOffset() ()
          Returns the offset within the document of the start of the change.
 String sample code for java.lang.String definition code for java.lang.String getPresentationName sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getPresentationName() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getPresentationName() ()
          Provides a localized, human readable description of this edit suitable for use in, say, a change log.
 String sample code for java.lang.String definition code for java.lang.String getRedoPresentationName sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getRedoPresentationName() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getRedoPresentationName() ()
          Provides a localized, human readable description of the redoable form of this edit, e.g.
 DocumentEvent.EventType sample code for javax.swing.event.DocumentEvent.EventType definition code for javax.swing.event.DocumentEvent.EventType getType sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getType() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getType() ()
          Returns the type of event.
 String sample code for java.lang.String definition code for java.lang.String getUndoPresentationName sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getUndoPresentationName() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getUndoPresentationName() ()
          Provides a localized, human readable description of the undoable form of this edit, e.g.
 boolean isSignificant sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.isSignificant() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.isSignificant() ()
          DefaultDocument events are significant.
 void redo sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.redo() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.redo() ()
          Redoes a change.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.toString() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.toString() ()
          Returns a string description of the change event.
 void undo sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.undo() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.undo() ()
          Undoes a change.
 
Methods inherited from class javax.swing.undo.CompoundEdit sample code for javax.swing.undo.CompoundEdit definition code for javax.swing.undo.CompoundEdit
canRedo sample code for javax.swing.undo.CompoundEdit.canRedo() definition code for javax.swing.undo.CompoundEdit.canRedo() , canUndo sample code for javax.swing.undo.CompoundEdit.canUndo() definition code for javax.swing.undo.CompoundEdit.canUndo() , die sample code for javax.swing.undo.CompoundEdit.die() definition code for javax.swing.undo.CompoundEdit.die() , end sample code for javax.swing.undo.CompoundEdit.end() definition code for javax.swing.undo.CompoundEdit.end() , isInProgress sample code for javax.swing.undo.CompoundEdit.isInProgress() definition code for javax.swing.undo.CompoundEdit.isInProgress() , lastEdit sample code for javax.swing.undo.CompoundEdit.lastEdit() definition code for javax.swing.undo.CompoundEdit.lastEdit()
 
Methods inherited from class javax.swing.undo.AbstractUndoableEdit sample code for javax.swing.undo.AbstractUndoableEdit definition code for javax.swing.undo.AbstractUndoableEdit
replaceEdit sample code for javax.swing.undo.AbstractUndoableEdit.replaceEdit(javax.swing.undo.UndoableEdit) definition code for javax.swing.undo.AbstractUndoableEdit.replaceEdit(javax.swing.undo.UndoableEdit)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

AbstractDocument.DefaultDocumentEvent sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent(int, int, javax.swing.event.DocumentEvent.EventType) definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent(int, int, javax.swing.event.DocumentEvent.EventType)

public AbstractDocument.DefaultDocumentEvent(int offs,
                                             int len,
                                             DocumentEvent.EventType sample code for javax.swing.event.DocumentEvent.EventType definition code for javax.swing.event.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)
Method Detail

toString sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.toString() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Returns a string description of the change event.

Overrides:
toString sample code for javax.swing.undo.CompoundEdit.toString() definition code for javax.swing.undo.CompoundEdit.toString() in class CompoundEdit sample code for javax.swing.undo.CompoundEdit definition code for javax.swing.undo.CompoundEdit
Returns:
a string

addEdit sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.addEdit(javax.swing.undo.UndoableEdit) definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.addEdit(javax.swing.undo.UndoableEdit)

public boolean addEdit(UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.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.

Specified by:
addEdit sample code for javax.swing.undo.UndoableEdit.addEdit(javax.swing.undo.UndoableEdit) definition code for javax.swing.undo.UndoableEdit.addEdit(javax.swing.undo.UndoableEdit) in interface UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit
Overrides:
addEdit sample code for javax.swing.undo.CompoundEdit.addEdit(javax.swing.undo.UndoableEdit) definition code for javax.swing.undo.CompoundEdit.addEdit(javax.swing.undo.UndoableEdit) in class CompoundEdit sample code for javax.swing.undo.CompoundEdit definition code for javax.swing.undo.CompoundEdit
Parameters:
anEdit - a document edit record
Returns:
true if the edit was added
See Also:
UndoableEdit.addEdit(javax.swing.undo.UndoableEdit) sample code for javax.swing.undo.UndoableEdit.addEdit(javax.swing.undo.UndoableEdit) definition code for javax.swing.undo.UndoableEdit.addEdit(javax.swing.undo.UndoableEdit)

redo sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.redo() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.redo()

public void redo()
          throws CannotRedoException sample code for javax.swing.undo.CannotRedoException definition code for javax.swing.undo.CannotRedoException 
Redoes a change.

Specified by:
redo sample code for javax.swing.undo.UndoableEdit.redo() definition code for javax.swing.undo.UndoableEdit.redo() in interface UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit
Overrides:
redo sample code for javax.swing.undo.CompoundEdit.redo() definition code for javax.swing.undo.CompoundEdit.redo() in class CompoundEdit sample code for javax.swing.undo.CompoundEdit definition code for javax.swing.undo.CompoundEdit
Throws:
CannotRedoException sample code for javax.swing.undo.CannotRedoException definition code for javax.swing.undo.CannotRedoException - if the change cannot be redone
See Also:
AbstractUndoableEdit.canRedo() sample code for javax.swing.undo.AbstractUndoableEdit.canRedo() definition code for javax.swing.undo.AbstractUndoableEdit.canRedo()

undo sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.undo() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.undo()

public void undo()
          throws CannotUndoException sample code for javax.swing.undo.CannotUndoException definition code for javax.swing.undo.CannotUndoException 
Undoes a change.

Specified by:
undo sample code for javax.swing.undo.UndoableEdit.undo() definition code for javax.swing.undo.UndoableEdit.undo() in interface UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit
Overrides:
undo sample code for javax.swing.undo.CompoundEdit.undo() definition code for javax.swing.undo.CompoundEdit.undo() in class CompoundEdit sample code for javax.swing.undo.CompoundEdit definition code for javax.swing.undo.CompoundEdit
Throws:
CannotUndoException sample code for javax.swing.undo.CannotUndoException definition code for javax.swing.undo.CannotUndoException - if the change cannot be undone
See Also:
AbstractUndoableEdit.canUndo() sample code for javax.swing.undo.AbstractUndoableEdit.canUndo() definition code for javax.swing.undo.AbstractUndoableEdit.canUndo()

isSignificant sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.isSignificant() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.isSignificant()

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.

Specified by:
isSignificant sample code for javax.swing.undo.UndoableEdit.isSignificant() definition code for javax.swing.undo.UndoableEdit.isSignificant() in interface UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit
Overrides:
isSignificant sample code for javax.swing.undo.CompoundEdit.isSignificant() definition code for javax.swing.undo.CompoundEdit.isSignificant() in class CompoundEdit sample code for javax.swing.undo.CompoundEdit definition code for javax.swing.undo.CompoundEdit
Returns:
whether the event is significant for edit undo purposes
See Also:
UndoableEdit.isSignificant() sample code for javax.swing.undo.UndoableEdit.isSignificant() definition code for javax.swing.undo.UndoableEdit.isSignificant()

getPresentationName sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getPresentationName() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getPresentationName()

public String sample code for java.lang.String definition code for java.lang.String  getPresentationName()
Provides a localized, human readable description of this edit suitable for use in, say, a change log.

Specified by:
getPresentationName sample code for javax.swing.undo.UndoableEdit.getPresentationName() definition code for javax.swing.undo.UndoableEdit.getPresentationName() in interface UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit
Overrides:
getPresentationName sample code for javax.swing.undo.CompoundEdit.getPresentationName() definition code for javax.swing.undo.CompoundEdit.getPresentationName() in class CompoundEdit sample code for javax.swing.undo.CompoundEdit definition code for javax.swing.undo.CompoundEdit
Returns:
the description
See Also:
AbstractUndoableEdit.getUndoPresentationName() sample code for javax.swing.undo.AbstractUndoableEdit.getUndoPresentationName() definition code for javax.swing.undo.AbstractUndoableEdit.getUndoPresentationName() , AbstractUndoableEdit.getRedoPresentationName() sample code for javax.swing.undo.AbstractUndoableEdit.getRedoPresentationName() definition code for javax.swing.undo.AbstractUndoableEdit.getRedoPresentationName()

getUndoPresentationName sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getUndoPresentationName() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getUndoPresentationName()

public String sample code for java.lang.String definition code for java.lang.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();

Specified by:
getUndoPresentationName sample code for javax.swing.undo.UndoableEdit.getUndoPresentationName() definition code for javax.swing.undo.UndoableEdit.getUndoPresentationName() in interface UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit
Overrides:
getUndoPresentationName sample code for javax.swing.undo.CompoundEdit.getUndoPresentationName() definition code for javax.swing.undo.CompoundEdit.getUndoPresentationName() in class CompoundEdit sample code for javax.swing.undo.CompoundEdit definition code for javax.swing.undo.CompoundEdit
Returns:
the description
See Also:
AbstractUndoableEdit.getPresentationName() sample code for javax.swing.undo.AbstractUndoableEdit.getPresentationName() definition code for javax.swing.undo.AbstractUndoableEdit.getPresentationName()

getRedoPresentationName sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getRedoPresentationName() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getRedoPresentationName()

public String sample code for java.lang.String definition code for java.lang.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();

Specified by:
getRedoPresentationName sample code for javax.swing.undo.UndoableEdit.getRedoPresentationName() definition code for javax.swing.undo.UndoableEdit.getRedoPresentationName() in interface UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit
Overrides:
getRedoPresentationName sample code for javax.swing.undo.CompoundEdit.getRedoPresentationName() definition code for javax.swing.undo.CompoundEdit.getRedoPresentationName() in class CompoundEdit sample code for javax.swing.undo.CompoundEdit definition code for javax.swing.undo.CompoundEdit
Returns:
the description
See Also:
AbstractUndoableEdit.getPresentationName() sample code for javax.swing.undo.AbstractUndoableEdit.getPresentationName() definition code for javax.swing.undo.AbstractUndoableEdit.getPresentationName()

getType sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getType() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getType()

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

Specified by:
getType sample code for javax.swing.event.DocumentEvent.getType() definition code for javax.swing.event.DocumentEvent.getType() in interface DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent
Returns:
the event type as a DocumentEvent.EventType
See Also:
DocumentEvent.getType() sample code for javax.swing.event.DocumentEvent.getType() definition code for javax.swing.event.DocumentEvent.getType()

getOffset sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getOffset() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getOffset()

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

Specified by:
getOffset sample code for javax.swing.event.DocumentEvent.getOffset() definition code for javax.swing.event.DocumentEvent.getOffset() in interface DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent
Returns:
the offset >= 0
See Also:
DocumentEvent.getOffset() sample code for javax.swing.event.DocumentEvent.getOffset() definition code for javax.swing.event.DocumentEvent.getOffset()

getLength sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getLength() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getLength()

public int getLength()
Returns the length of the change.

Specified by:
getLength sample code for javax.swing.event.DocumentEvent.getLength() definition code for javax.swing.event.DocumentEvent.getLength() in interface DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent
Returns:
the length >= 0
See Also:
DocumentEvent.getLength() sample code for javax.swing.event.DocumentEvent.getLength() definition code for javax.swing.event.DocumentEvent.getLength()

getDocument sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getDocument() definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getDocument()

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

Specified by:
getDocument sample code for javax.swing.event.DocumentEvent.getDocument() definition code for javax.swing.event.DocumentEvent.getDocument() in interface DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent
Returns:
the document
See Also:
DocumentEvent.getDocument() sample code for javax.swing.event.DocumentEvent.getDocument() definition code for javax.swing.event.DocumentEvent.getDocument()

getChange sample code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getChange(javax.swing.text.Element) definition code for javax.swing.text.AbstractDocument.DefaultDocumentEvent.getChange(javax.swing.text.Element)

public 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 changes for an element.

Specified by:
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) in interface DocumentEvent sample code for javax.swing.event.DocumentEvent definition code for javax.swing.event.DocumentEvent
Parameters:
elem - the element
Returns:
the changes