home *** CD-ROM | disk | FTP | other *** search
/ Australian PC Authority 1999 May / may1999.iso / May / JBUILDER / JSAMPLES.Z / Notepad$UndoAction.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-30  |  1.7 KB  |  38 lines

  1. import com.sun.java.swing.AbstractAction;
  2. import com.sun.java.swing.undo.CannotUndoException;
  3. import java.awt.event.ActionEvent;
  4.  
  5. class Notepad$UndoAction extends AbstractAction {
  6.    // $FF: synthetic field
  7.    private final Notepad this$0;
  8.  
  9.    public Notepad$UndoAction(Notepad var1) {
  10.       super("Undo");
  11.       this.this$0 = var1;
  12.       this.this$0 = var1;
  13.       ((AbstractAction)this).setEnabled(false);
  14.    }
  15.  
  16.    public void actionPerformed(ActionEvent var1) {
  17.       try {
  18.          this.this$0.undo.undo();
  19.       } catch (CannotUndoException var3) {
  20.          System.out.println("Unable to undo: " + var3);
  21.          ((Throwable)var3).printStackTrace();
  22.       }
  23.  
  24.       this.update();
  25.       Notepad.access$0(this.this$0).update();
  26.    }
  27.  
  28.    protected void update() {
  29.       if (this.this$0.undo.canUndo()) {
  30.          ((AbstractAction)this).setEnabled(true);
  31.          ((AbstractAction)this).putValue("Name", this.this$0.undo.getUndoPresentationName());
  32.       } else {
  33.          ((AbstractAction)this).setEnabled(false);
  34.          ((AbstractAction)this).putValue("Name", "Undo");
  35.       }
  36.    }
  37. }
  38.