home *** CD-ROM | disk | FTP | other *** search
/ Java by Example / jbecd.bin / JBE-CD / NTUsers / JBECODE.ZIP / JavaByExample / chap23 / CustomFrame.class (.txt) next >
Encoding:
Java Class File  |  1996-03-06  |  981 b   |  33 lines

  1. import java.awt.Button;
  2. import java.awt.Component;
  3. import java.awt.Container;
  4. import java.awt.Event;
  5. import java.awt.FlowLayout;
  6. import java.awt.Frame;
  7. import java.awt.Graphics;
  8.  
  9. class CustomFrame extends Frame {
  10.    Button button;
  11.  
  12.    CustomFrame(String var1) {
  13.       super(var1);
  14.       FlowLayout var2 = new FlowLayout();
  15.       ((Container)this).setLayout(var2);
  16.       this.button = new Button("Close Window");
  17.       ((Container)this).add(this.button);
  18.    }
  19.  
  20.    public void paint(Graphics var1) {
  21.       ((Component)this).resize(200, 100);
  22.       var1.drawString("This is a custom window.", 30, 50);
  23.    }
  24.  
  25.    public boolean action(Event var1, Object var2) {
  26.       if (var2 == "Close Window") {
  27.          ((Frame)this).dispose();
  28.       }
  29.  
  30.       return true;
  31.    }
  32. }
  33.