public void undo(){
  try {
    if (undoManager.canUndo()) {
      undoManager.undo();
      for (      KeyListener kl : getKeyListeners()) {
        kl.keyTyped(null);
        kl.keyReleased(null);
      }
    }
  }
 catch (  CannotUndoException e) {
  }
}

public void undo ( ) { try { if ( undoManager . canUndo ( ) ) { undoManager . undo ( ) ; for ( KeyListener kl : getKeyListeners ( ) ) { kl . keyTyped ( null ) ; kl . keyReleased ( null ) ; } } } catch ( CannotUndoException e ) { } }
undoes the last action , if any has been performed .
