模块 java.desktop

类 StateEdit

所有已实现的接口:
Serializable , UndoableEdit

public class StateEdit extends AbstractUndoableEdit

StateEdit 是对改变状态的对象的一般编辑。被编辑的对象必须符合 StateEditable 接口。

此编辑类通过要求对象在编辑发生前后将其状态存储在哈希表中来工作。在撤消或重做时,对象被告知从这些哈希表中恢复它的状态。

状态编辑使用如下:
   // Create the edit during the "before" state of the object
   StateEdit newEdit = new StateEdit(myObject);
   // Modify the object
   myObject.someStateModifyingMethod();
   // "end" the edit when you are done modifying the object
   newEdit.end();
 

Note that when a StateEdit ends, it removes redundant state from the Hashtables - A state Hashtable is not guaranteed to contain all keys/values placed into it when the state is stored!

参见: