- 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 inherited from interface javax.swing.event.DocumentEvent
DocumentEvent.ElementChange, DocumentEvent.EventType
-
-
Field Summary
-
Fields inherited from class javax.swing.undo.CompoundEdit
edits
-
-
Constructor Summary
Constructors Constructor and Description AbstractDocument.DefaultDocumentEvent(int offs, int len, DocumentEvent.EventType type)Constructs a change record.
-
Method Summary
Methods Modifier and Type Method and Description booleanaddEdit(UndoableEdit anEdit)Adds a document edit.DocumentEvent.ElementChangegetChange(Element elem)Gets the changes for an element.DocumentgetDocument()Gets the document that sourced the change event.intgetLength()Returns the length of the change.intgetOffset()Returns the offset within the document of the start of the change.StringgetPresentationName()Provides a localized, human readable description of this edit suitable for use in, say, a change log.StringgetRedoPresentationName()Provides a localized, human readable description of the redoable form of this edit, e.g.DocumentEvent.EventTypegetType()Returns the type of event.StringgetUndoPresentationName()Provides a localized, human readable description of the undoable form of this edit, e.g.booleanisSignificant()DefaultDocument events are significant.voidredo()Redoes a change.StringtoString()Returns a string description of the change event.voidundo()Undoes a change.-
Methods inherited from class javax.swing.undo.CompoundEdit
canRedo, canUndo, die, end, isInProgress, lastEdit
-
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
replaceEdit
-
-
-
-
Constructor Detail
-
AbstractDocument.DefaultDocumentEvent
public AbstractDocument.DefaultDocumentEvent(int offs, int len, DocumentEvent.EventType type)Constructs a change record.- Parameters:
offs- the offset into the document of the change >= 0len- the length of the change >= 0type- the type of event (DocumentEvent.EventType)- Since:
- 1.4
-
-
Method Detail
-
toString
public String toString()
Returns a string description of the change event.- Overrides:
toStringin classCompoundEdit- 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:
addEditin interfaceUndoableEdit- Overrides:
addEditin classCompoundEdit- Parameters:
anEdit- a document edit record- Returns:
- true if the edit was added
- See Also:
UndoableEdit.addEdit(javax.swing.undo.UndoableEdit)
-
redo
public void redo() throws CannotRedoExceptionRedoes a change.- Specified by:
redoin interfaceUndoableEdit- Overrides:
redoin classCompoundEdit- Throws:
CannotRedoException- if the change cannot be redone- See Also:
AbstractUndoableEdit.canRedo()
-
undo
public void undo() throws CannotUndoExceptionUndoes a change.- Specified by:
undoin interfaceUndoableEdit- Overrides:
undoin classCompoundEdit- 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:
isSignificantin interfaceUndoableEdit- Overrides:
isSignificantin classCompoundEdit- 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:
getPresentationNamein interfaceUndoableEdit- Overrides:
getPresentationNamein classCompoundEdit- 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:
getUndoPresentationNamein interfaceUndoableEdit- Overrides:
getUndoPresentationNamein classCompoundEdit- 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:
getRedoPresentationNamein interfaceUndoableEdit- Overrides:
getRedoPresentationNamein classCompoundEdit- Returns:
- the description
- See Also:
AbstractUndoableEdit.getPresentationName()
-
getType
public DocumentEvent.EventType getType()
Returns the type of event.- Specified by:
getTypein interfaceDocumentEvent- 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:
getOffsetin interfaceDocumentEvent- Returns:
- the offset >= 0
- See Also:
DocumentEvent.getOffset()
-
getLength
public int getLength()
Returns the length of the change.- Specified by:
getLengthin interfaceDocumentEvent- Returns:
- the length >= 0
- See Also:
DocumentEvent.getLength()
-
getDocument
public Document getDocument()
Gets the document that sourced the change event.- Specified by:
getDocumentin interfaceDocumentEvent- Returns:
- the document
- See Also:
DocumentEvent.getDocument()
-
getChange
public DocumentEvent.ElementChange getChange(Element elem)
Gets the changes for an element.- Specified by:
getChangein interfaceDocumentEvent- Parameters:
elem- the element- Returns:
- the changes
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/swing/text/abstractdocument.defaultdocumentevent.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.