javax.swing.undo package contains two interfaces and seven classes (two of
which are exception classes). These, along with a listener interface and
event class from the
javax.swing.event package, comprise the undo
facility shown in Figure
Figure 18-1. The Swing undo facility
Here is a brief overview of each class:
The base interface for just about everything else in the undo package. It serves as an abstraction for anything in an application that can be undone.
The default implementation of
UndoableEdit provides a starting point
for building new
classes. It provides a simple set of rules for determining whether
undo and redo requests are allowable (based on whether the edit
has already been undone, redone, or killed). Despite its name, it
is not an abstract class. This is really just a technicality since
the default implementation is not at all useful as it is, so you’d
never want to instantiate one.
This extension of
AbstractUndoableEdit allows multiple
edits to be grouped together into a single edit. Those familiar
with the classic Design Patterns by Erich
Gamma et al. (Addison-Wesley) will recognize this construct as a
basic implementation of the Composite pattern.
This event class can be used to notify listeners that an undoable edit has been made.