Example usage for javax.swing.undo UndoManager undo

List of usage examples for javax.swing.undo UndoManager undo

Introduction

In this page you can find the example usage for javax.swing.undo UndoManager undo.

Prototype

public void undo() throws CannotUndoException 

Source Link

Document

Undoes the appropriate edits.

Usage

From source file:org.pmedv.blackboard.commands.UndoCommand.java

@Override
public void execute(ActionEvent e) {
    ApplicationContext ctx = AppContext.getContext();
    ApplicationWindow win = ctx.getBean(ApplicationWindow.class);
    BoardEditor editor = EditorUtils.getCurrentActiveEditor();
    UndoManager undoManager = editor.getUndoManager();

    try {//w  w  w.  j  a  v a  2s.  c o m

        try {
            undoManager.undo();
        } catch (CannotUndoException c) {
            JOptionPane.showMessageDialog(win, resources.getResourceByKey("msg.cantundo"),
                    resources.getResourceByKey("msg.error"), JOptionPane.ERROR_MESSAGE);
        }

    } catch (CannotUndoException e1) {
        log.warn("Cannot undo.");
        e1.printStackTrace();
    }

    ctx.getBean(RedoCommand.class).setEnabled(undoManager.canRedo());
    ctx.getBean(UndoCommand.class).setEnabled(undoManager.canUndo());
}