java.lang.Objectjavax.swing.undo.AbstractUndoableEdit
javax.swing.undo.CompoundEdit
javax.swing.undo.UndoManager
public class UndoManager
Concrete subclass of CompoundEdit
which can serve as a UndoableEditListener,
consolidating the UndoableEditEvents from a
variety of sources, and undoing or redoing them one at a time.
Unlike AbstractUndoableEdit and CompoundEdit,
the public methods of this
class are synchronized, and should be safe to call from multiple
threads. This should make UndoManager
a convenient marshall for sets of undoable JavaBeans.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans package.
Please see XMLEncoder.
| Field Summary |
|---|
| Fields inherited from class javax.swing.undo.CompoundEdit |
|---|
edits |
| Fields inherited from class javax.swing.undo.AbstractUndoableEdit |
|---|
RedoName, UndoName |
| Constructor Summary | |
|---|---|
UndoManager()
|
|
| Method Summary | |
|---|---|
boolean |
addEdit(UndoableEdit anEdit)
If inProgress, inserts anEdit at indexOfNextAdd, and removes any old edits that were at indexOfNextAdd or later. |
boolean |
canRedo()
Overridden to preserve usual semantics: returns true if a redo operation would be successful now, false otherwise |
boolean |
canUndo()
Overridden to preserve usual semantics: returns true if an undo operation would be successful now, false otherwise |
boolean |
canUndoOrRedo()
Return true if calling undoOrRedo will undo or redo. |
void |
discardAllEdits()
Empty the undo manager, sending each edit a die message in the process. |
protected UndoableEdit |
editToBeRedone()
Returns the the next significant edit to be redone if redo is called. |
protected UndoableEdit |
editToBeUndone()
Returns the the next significant edit to be undone if undo is called. |
void |
end()
Sending end() to an UndoManager turns it into a plain old (ended) CompoundEdit. |
int |
getLimit()
Returns the maximum number of edits this UndoManager will hold. |
String |
getRedoPresentationName()
If inProgress, returns getRedoPresentationName of the significant edit that will be redone when redo() is invoked. |
String |
getUndoOrRedoPresentationName()
Return the appropriate name for a command that toggles between undo and redo. |
String |
getUndoPresentationName()
If inProgress, returns getUndoPresentationName of the significant edit that will be undone when undo() is invoked. |
void |
redo()
If this UndoManager is inProgress,
redoes the last significant UndoableEdit at
indexOfNextAdd or after, and all insignificant
edits up to it. |
protected void |
redoTo(UndoableEdit edit)
Redoes all changes from indexOfNextAdd to edit. |
void |
setLimit(int l)
Set the maximum number of edits this UndoManager will hold. |
String |
toString()
Returns a string that displays and identifies this object's properties. |
protected void |
trimEdits(int from,
int to)
Tell the edits in the given range (inclusive) to die, and remove them from edits. |
protected void |
trimForLimit()
Reduce the number of queued edits to a range of size limit, centered on indexOfNextAdd. |
void |
undo()
If this UndoManager is inProgress, undo the last significant UndoableEdit before indexOfNextAdd, and all insignificant edits back to it. |
void |
undoableEditHappened(UndoableEditEvent e)
Called by the UndoabledEdit sources this UndoManager listens to. |
void |
undoOrRedo()
Undo or redo as appropriate. |
protected void |
undoTo(UndoableEdit edit)
Undoes all changes from indexOfNextAdd to edit. |
| Methods inherited from class javax.swing.undo.CompoundEdit |
|---|
die, getPresentationName, isInProgress, isSignificant, lastEdit |
| Methods inherited from class javax.swing.undo.AbstractUndoableEdit |
|---|
replaceEdit |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public UndoManager()
| Method Detail |
|---|
public int getLimit()
public void discardAllEdits()
protected void trimForLimit()
protected void trimEdits(int from,
int to)
public void setLimit(int l)
protected UndoableEdit editToBeUndone()
protected UndoableEdit editToBeRedone()
protected void undoTo(UndoableEdit edit) throws CannotUndoException
CannotUndoExceptionprotected void redoTo(UndoableEdit edit) throws CannotRedoException
CannotRedoException
public void undoOrRedo()
throws CannotRedoException,
CannotUndoException
public boolean canUndoOrRedo()
undoOrRedo()
public void undo()
throws CannotUndoException
If not inProgress, indexOfNextAdd is ignored and super's routine is called.
undo in interface UndoableEditundo in class CompoundEditCannotUndoException - if canUndo
returns falseCompoundEdit.end()public boolean canUndo()
canUndo in interface UndoableEditcanUndo in class CompoundEditalive
and hasBeenDone is trueCompoundEdit.isInProgress()
public void redo()
throws CannotRedoException
UndoManager is inProgress,
redoes the last significant UndoableEdit at
indexOfNextAdd or after, and all insignificant
edits up to it. Updates indexOfNextAdd accordingly.
If not inProgress, indexOfNextAdd
is ignored and super's routine is called.
redo in interface UndoableEditredo in class CompoundEditCannotRedoException - if canRedo
returns falseCompoundEdit.end()public boolean canRedo()
canRedo in interface UndoableEditcanRedo in class CompoundEdittrue if this edit is alive
and hasBeenDone is falseCompoundEdit.isInProgress()public boolean addEdit(UndoableEdit anEdit)
If not inProgress, acts as a
CompoundEdit.
addEdit in interface UndoableEditaddEdit in class CompoundEditanEdit - the edit to be added
inProgress;
otherwise returns falseCompoundEdit.end(),
CompoundEdit.addEdit(javax.swing.undo.UndoableEdit)public void end()
Calls super's end() method (making inProgress false), then sends die() to the unreachable edits at indexOfNextAdd and beyond, in the reverse of the order in which they were added.
end in class CompoundEditCompoundEdit.end()public String getUndoOrRedoPresentationName()
public String getUndoPresentationName()
If not inProgress, acts as a CompoundEdit
getUndoPresentationName in interface UndoableEditgetUndoPresentationName in class CompoundEditAbstractUndoableEdit.undoText, followed
by a space, followed by getPresentationName
unless getPresentationName is "" in which
case, the defaults value is returned alone.undo(),
CompoundEdit.getUndoPresentationName()public String getRedoPresentationName()
If not inProgress, acts as a CompoundEdit
getRedoPresentationName in interface UndoableEditgetRedoPresentationName in class CompoundEditAbstractUndoableEdit.redoText, followed
by a space, followed by getPresentationName
unless getPresentationName is "" in which
case, the defaults value is returned alone.redo(),
CompoundEdit.getUndoPresentationName()public void undoableEditHappened(UndoableEditEvent e)
undoableEditHappened in interface UndoableEditListenerpublic String toString()
toString in class CompoundEditCes informations proviennent du site de http://java.sun.com
Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :
Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.
Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.
Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.
Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.
Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
7 mots clés dont 0 définis manuellement (plus d'information...).
Avertissement
Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.
Recherche (afficher)
Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
Citation (masquer)