GUI Commands User GuideVersion 2.1 |
||
Undo/Redo CommandsGUI Commands provides basic commands for handling undo and redo. The three core classes are:
To use the undo and redo commands you need to:
CommandContainer container = ...; // create and bind our commands UndoCommand undoCommand = new UndoCommand("undo"); UndoCommand redo = new UndoCommand("redo"); undoCommand.bind(container); redoCommand.bind(container); // configure the undo context. UndoContext undoContext = new UndoContext(); container.setUndoContext(undoContext); // use the context JTextPane textPane = ...; textPane.addUndoableEditListener(undoContext); You can change the UndoContext at any time. The commands will be notified of the change and update appropriately. |
||