Spec-Zone.ru › OpenJDK 27

Class AbstractDocument.DefaultDocumentEvent

java.lang.Object
javax.swing.undo.AbstractUndoableEdit
javax.swing.undo.CompoundEdit
javax.swing.text.AbstractDocument.DefaultDocumentEvent
All Implemented Interfaces:
Serializable, DocumentEvent, UndoableEdit
Enclosing class:
AbstractDocument
public class AbstractDocument.DefaultDocumentEvent extends CompoundEdit implements 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.

Nested Class Summary

Nested classes/interfaces declared in interface DocumentEvent

DocumentEvent.ElementChange, DocumentEvent.EventType
Modifier and Type Interface Description
static interface  DocumentEvent.ElementChange
Describes changes made to a specific element.
static final class  DocumentEvent.EventType
Enumeration for document event types

Field Summary

Fields declared in class CompoundEdit

edits
Modifier and Type Field Description
protected Vector<UndoableEdit> edits
The collection of UndoableEdits undone/redone en masse by this CompoundEdit.

Fields declared in class AbstractUndoableEdit

RedoName, UndoName
Modifier and Type Field Description
protected static final String RedoName
String returned by getRedoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used.
protected static final String UndoName
String returned by getUndoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used.

Constructor Summary

Constructor Description
DefaultDocumentEvent(int offs, int len, DocumentEvent.EventType type)
Constructs a change record.

Method Summary

Modifier and Type Method Description
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. for use as a Redo menu item.
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. for use as an Undo menu item.
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.

Methods declared in class CompoundEdit

canRedo, canUndo, die, end, isInProgress, lastEdit
Modifier and Type Method Description
boolean canRedo()
Returns false if isInProgress or if super returns false.
boolean canUndo()
Returns false if isInProgress or if super returns false.
void die()
Sends die to each subedit, in the reverse of the order that they were added.
void end()
Sets inProgress to false.
boolean isInProgress()
Returns true if this edit is in progress--that is, it has not received end.
protected UndoableEdit lastEdit()
Returns the last UndoableEdit in edits, or null if edits is empty.

Methods declared in class AbstractUndoableEdit

replaceEdit
Modifier and Type Method Description
boolean replaceEdit(UndoableEdit anEdit)
This default implementation returns false.

Methods declared in class Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Modifier and Type Method Description
protected Object clone()
Creates and returns a copy of this object.
boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.
protected void finalize()
Deprecated, for removal: This API element is subject to removal in a future version.
Finalization is deprecated and subject to removal in a future release.
final Class<?> getClass()
Returns the runtime class of this Object.
int hashCode()
Returns a hash code value for this object.
final void notify()
Wakes up a single thread that is waiting on this object's monitor.
final void notifyAll()
Wakes up all threads that are waiting on this object's monitor.
final void wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
final void wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final void wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

Constructor Details

DefaultDocumentEvent

public 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)
Since:
1.4

Method Details

toString

public String toString()
Returns a string description of the change event.
Overrides:
toString in class CompoundEdit
Returns:
a string

addEdit

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.
Specified by:
addEdit in interface UndoableEdit
Overrides:
addEdit in class CompoundEdit
Parameters:
anEdit - a document edit record
Returns:
true if the edit was added
See Also:
  • UndoableEdit.addEdit(UndoableEdit)

redo

public void redo() throws CannotRedoException
Redoes a change.
Specified by:
redo in interface UndoableEdit
Overrides:
redo in class CompoundEdit
Throws:
CannotRedoException - if the change cannot be redone
See Also:
  • AbstractUndoableEdit.canRedo()

undo

public void undo() throws CannotUndoException
Undoes a change.
Specified by:
undo in interface UndoableEdit
Overrides:
undo in class CompoundEdit
Throws:
CannotUndoException - if the change cannot be undone
See Also:
  • AbstractUndoableEdit.canUndo()

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 in interface UndoableEdit
Overrides:
isSignificant in class CompoundEdit
Returns:
whether the event is significant for edit undo purposes
See Also:
  • UndoableEdit.isSignificant()

getPresentationName

public String getPresentationName()
Provides a localized, human readable description of this edit suitable for use in, say, a change log.
Specified by:
getPresentationName in interface UndoableEdit
Overrides:
getPresentationName in class CompoundEdit
Returns:
the description
See Also:
  • AbstractUndoableEdit.getUndoPresentationName()
  • AbstractUndoableEdit.getRedoPresentationName()

getUndoPresentationName

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();
Specified by:
getUndoPresentationName in interface UndoableEdit
Overrides:
getUndoPresentationName in class CompoundEdit
Returns:
the description
See Also:
  • AbstractUndoableEdit.getPresentationName()

getRedoPresentationName

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();
Specified by:
getRedoPresentationName in interface UndoableEdit
Overrides:
getRedoPresentationName in class CompoundEdit
Returns:
the description
See Also:
  • AbstractUndoableEdit.getPresentationName()

getType

public DocumentEvent.EventType getType()
Returns the type of event.
Specified by:
getType in interface DocumentEvent
Returns:
the event type as a DocumentEvent.EventType
See Also:
  • DocumentEvent.getType()

getOffset

public int getOffset()
Returns the offset within the document of the start of the change.
Specified by:
getOffset in interface DocumentEvent
Returns:
the offset >= 0
See Also:
  • DocumentEvent.getOffset()

getLength

public int getLength()
Returns the length of the change.
Specified by:
getLength in interface DocumentEvent
Returns:
the length >= 0
See Also:
  • DocumentEvent.getLength()

getDocument

public Document getDocument()
Gets the document that sourced the change event.
Specified by:
getDocument in interface DocumentEvent
Returns:
the document
See Also:
  • DocumentEvent.getDocument()

getChange

public DocumentEvent.ElementChange getChange(Element elem)
Gets the changes for an element.
Specified by:
getChange in interface DocumentEvent
Parameters:
elem - the element
Returns:
the changes

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2026, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API