- java.lang.Object
-
- javax.swing.undo.AbstractUndoableEdit
-
- javax.swing.text.AbstractDocument.ElementEdit
-
- All Implemented Interfaces:
- Serializable, DocumentEvent.ElementChange, UndoableEdit
- Enclosing class:
- AbstractDocument
public static class AbstractDocument.ElementEdit extends AbstractUndoableEdit implements DocumentEvent.ElementChange
An implementation of ElementChange that can be added to the document event.
-
-
Constructor Summary
Constructors Constructor and Description AbstractDocument.ElementEdit(Element e, int index, Element[] removed, Element[] added)
Constructs an edit record.
-
Method Summary
Methods Modifier and Type Method and Description Element[]
getChildrenAdded()
Gets a list of children that were added.Element[]
getChildrenRemoved()
Gets a list of children that were removed.Element
getElement()
Returns the underlying element.int
getIndex()
Returns the index into the list of elements.void
redo()
Redoes a change.void
undo()
Undoes a change.-
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
addEdit, canRedo, canUndo, die, getPresentationName, getRedoPresentationName, getUndoPresentationName, isSignificant, replaceEdit, toString
-
-
-
-
Constructor Detail
-
AbstractDocument.ElementEdit
public AbstractDocument.ElementEdit(Element e, int index, Element[] removed, Element[] added)
Constructs an edit record. This does not modify the element so it can safely be used to catch up a view to the current model state for views that just attached to a model.- Parameters:
e
- the elementindex
- the index into the model >= 0removed
- a set of elements that were removedadded
- a set of elements that were added
-
-
Method Detail
-
getElement
public Element getElement()
Returns the underlying element.- Specified by:
getElement
in interfaceDocumentEvent.ElementChange
- Returns:
- the element
-
getIndex
public int getIndex()
Returns the index into the list of elements.- Specified by:
getIndex
in interfaceDocumentEvent.ElementChange
- Returns:
- the index >= 0
-
getChildrenRemoved
public Element[] getChildrenRemoved()
Gets a list of children that were removed.- Specified by:
getChildrenRemoved
in interfaceDocumentEvent.ElementChange
- Returns:
- the list
-
getChildrenAdded
public Element[] getChildrenAdded()
Gets a list of children that were added.- Specified by:
getChildrenAdded
in interfaceDocumentEvent.ElementChange
- Returns:
- the list
-
redo
public void redo() throws CannotRedoException
Redoes a change.- Specified by:
redo
in interfaceUndoableEdit
- Overrides:
redo
in classAbstractUndoableEdit
- 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 interfaceUndoableEdit
- Overrides:
undo
in classAbstractUndoableEdit
- Throws:
CannotUndoException
- if the change cannot be undone- See Also:
AbstractUndoableEdit.canUndo()
-
-
Document created the 11/06/2005, last modified the 04/03/2020
Source of the printed document:https://www.gaudry.be/en/java-api-rf-javax/swing/text/abstractdocument.elementedit.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.