public void undo(){
  try {
    if (undoManager != null)     undoManager.undoOrRedo();
  }
 catch (  CannotUndoException ignored) {
  }
catch (  CannotRedoException ignored) {
  }
}

public void undo ( ) { try { if ( undoManager != null ) undoManager . undoOrRedo ( ) ; } catch ( CannotUndoException ignored ) { } catch ( CannotRedoException ignored ) { } }
undoes the last action .
