Example usage for javax.swing.undo UndoManager canRedo

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

Introduction

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

Prototype

public synchronized boolean canRedo() 

Source Link

Document

Returns true if edits may be redone.

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 {//from   w  ww  .j  av a  2  s  .c om

        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());
}