home *** CD-ROM | disk | FTP | other *** search
/ Java by Example / jbecd.bin / JBE-CD / NTUsers / JBECODE.ZIP / JavaByExample / chap18 / ButtonApplet.class (.txt) next >
Encoding:
Java Class File  |  1996-02-23  |  1.1 KB  |  42 lines

  1. import java.applet.Applet;
  2. import java.awt.Button;
  3. import java.awt.Container;
  4. import java.awt.Event;
  5.  
  6. public class ButtonApplet extends Applet {
  7.    Button button1;
  8.    Button button2;
  9.    Button button3;
  10.  
  11.    public void init() {
  12.       this.button1 = new Button("Button1");
  13.       this.button2 = new Button("Button2");
  14.       this.button3 = new Button("Button3");
  15.       ((Container)this).add(this.button1);
  16.       ((Container)this).add(this.button2);
  17.       ((Container)this).add(this.button3);
  18.    }
  19.  
  20.    public boolean action(Event var1, Object var2) {
  21.       if (var1.target instanceof Button) {
  22.          this.HandleButtons(var2);
  23.       }
  24.  
  25.       return true;
  26.    }
  27.  
  28.    protected void HandleButtons(Object var1) {
  29.       if (var1 == "Button1") {
  30.          this.button1.setLabel("1nottuB");
  31.       } else if (var1 == "Button2") {
  32.          this.button2.setLabel("2nottuB");
  33.       } else if (var1 == "Button3") {
  34.          this.button3.setLabel("3nottuB");
  35.       } else {
  36.          this.button1.setLabel("Button1");
  37.          this.button2.setLabel("Button2");
  38.          this.button3.setLabel("Button3");
  39.       }
  40.    }
  41. }
  42.