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

  1. import com.sun.java.swing.AbstractAction;
  2. import com.sun.java.swing.text.Document;
  3. import java.awt.FileDialog;
  4. import java.awt.Frame;
  5. import java.awt.event.ActionEvent;
  6. import java.io.File;
  7. import java.io.FileInputStream;
  8. import java.io.IOException;
  9. import java.io.ObjectInputStream;
  10.  
  11. class Stylepad$OpenAction extends AbstractAction {
  12.    // $FF: synthetic field
  13.    private final Stylepad this$0;
  14.  
  15.    Stylepad$OpenAction(Stylepad var1) {
  16.       super("open");
  17.       this.this$0 = var1;
  18.       this.this$0 = var1;
  19.    }
  20.  
  21.    public void actionPerformed(ActionEvent var1) {
  22.       Frame var2 = this.this$0.getFrame();
  23.       if (this.this$0.fileDialog == null) {
  24.          this.this$0.fileDialog = new FileDialog(var2);
  25.       }
  26.  
  27.       this.this$0.fileDialog.setMode(0);
  28.       this.this$0.fileDialog.show();
  29.       String var3 = this.this$0.fileDialog.getFile();
  30.       if (var3 != null) {
  31.          String var4 = this.this$0.fileDialog.getDirectory();
  32.          File var5 = new File(var4, var3);
  33.          if (var5.exists()) {
  34.             try {
  35.                FileInputStream var6 = new FileInputStream(var5);
  36.                ObjectInputStream var7 = new ObjectInputStream(var6);
  37.                Document var8 = (Document)var7.readObject();
  38.                this.this$0.getEditor().setDocument(var8);
  39.                var2.setTitle(var3);
  40.                this.this$0.validate();
  41.             } catch (IOException var9) {
  42.                System.err.println("IOException: " + ((Throwable)var9).getMessage());
  43.             } catch (ClassNotFoundException var10) {
  44.                System.err.println("Class not found: " + ((Throwable)var10).getMessage());
  45.             }
  46.          } else {
  47.             System.err.println("No such file: " + var5);
  48.          }
  49.       }
  50.    }
  51. }
  52.