javax.swing.undo

Interface StateEditable

public interface StateEditable

The interface for objects whose state can be undone or redone by a {@link StateEdit} action.

The following example shows how to write a class that implements this interface.

 class Foo
   implements StateEditable
 {
   private String name;

   public void setName(String n) { name = n; }

   public void restoreState(Hashtable h)
   {
     if (h.containsKey("name"))
       setName((String) h.get("name"));
   }

   public void storeState(Hashtable s)
   {
     s.put("name", name);
   }
 }

See Also:

Field Summary
StringRCSID
The ID of the Java source file in Sun’s Revision Control System (RCS).
Method Summary
voidrestoreState(Hashtable<?,?> state)
Performs an edit action, taking any editable state information from the specified hash table.
voidstoreState(Hashtable<Object,Object> state)
Stores any editable state information into the specified hash table.

Field Detail

RCSID

public String RCSID
The ID of the Java source file in Sun’s Revision Control System (RCS). This certainly should not be part of the API specification. But in order to be API-compatible with Sun’s reference implementation, GNU Classpath also has to provide this field and match its value. The value used here has been in every JDK release at least from 1.2 to 1.5.

Method Detail

restoreState

public void restoreState(Hashtable<?,?> state)
Performs an edit action, taking any editable state information from the specified hash table.

Note to implementors of this interface: To increase efficiency, the StateEdit class {@link StateEdit#removeRedundantState()} removes redundant state information. Therefore, implementations of this interface must be prepared for the case where certain keys were stored into the table by {@link #storeState}, but are not present anymore when the restoreState method gets called.

Parameters: state a hash table containing the relevant state information.

storeState

public void storeState(Hashtable<Object,Object> state)
Stores any editable state information into the specified hash table.

Parameters: state a hash table for storing relevant state information.