home *** CD-ROM | disk | FTP | other *** search
/ Java by Example / jbecd.bin / JBE-CD / NTUsers / JBECODE.ZIP / JavaByExample / chap22 / CardApplet2.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-03-05  |  1.7 KB  |  52 lines

  1. import java.applet.Applet;
  2. import java.awt.Button;
  3. import java.awt.CardLayout;
  4. import java.awt.Container;
  5. import java.awt.Event;
  6. import java.awt.List;
  7. import java.awt.Panel;
  8. import java.awt.TextField;
  9.  
  10. public class CardApplet2 extends Applet {
  11.    CardLayout cardLayout;
  12.    Panel panel;
  13.    Panel card1;
  14.    Panel card2;
  15.    Panel card3;
  16.    Button button1;
  17.    Button button2;
  18.    Button button3;
  19.    List list;
  20.    TextField textField;
  21.  
  22.    public void init() {
  23.       this.panel = new Panel();
  24.       ((Container)this).add(this.panel);
  25.       this.card1 = new Panel();
  26.       this.card2 = new Panel();
  27.       this.card3 = new Panel();
  28.       this.cardLayout = new CardLayout(0, 0);
  29.       this.panel.setLayout(this.cardLayout);
  30.       this.panel.add("Card1", this.card1);
  31.       this.panel.add("Card2", this.card2);
  32.       this.panel.add("Card3", this.card3);
  33.       this.button1 = new Button("Button1");
  34.       this.button2 = new Button("Button2");
  35.       this.button3 = new Button("Button3");
  36.       this.card1.add("Button1", this.button1);
  37.       this.card1.add("Button2", this.button2);
  38.       this.card1.add("Button3", this.button3);
  39.       this.list = new List(10, false);
  40.       this.list.addItem("Scrolling list");
  41.       this.card2.add("List", this.list);
  42.       this.textField = new TextField("", 30);
  43.       this.card3.add("TextField", this.textField);
  44.       ((Applet)this).resize(250, 250);
  45.    }
  46.  
  47.    public boolean action(Event var1, Object var2) {
  48.       this.cardLayout.next(this.panel);
  49.       return true;
  50.    }
  51. }
  52.