jgraph 之 撤销与恢复

JGraph graph = null;
graph = new JGraph(model, view);

GraphUndoManager undoManager = null;

undoManager = new GraphUndoManager();

graph.getModel().addUndoableEditListener(undoManager);

/**
* 撤销
*/
public void undo() {
// Register UndoManager with the Model
try {
undoManager.undo();
} catch (CannotUndoException e) {
e.printStackTrace();
}
}

/**
* redo
*/
public void redo() {
// Register UndoManager with the Model
try {
undoManager.redo();
} catch (CannotRedoException e) {
e.printStackTrace();
}
}

你可能感兴趣的:(jgraph)