FileDocCategorySizeDatePackage
CardLayoutExample.javaAPI DocExample1205Mon Sep 22 13:30:30 BST 1997None

CardLayoutExample

public class CardLayoutExample extends Applet

Fields Summary
Constructors Summary
Methods Summary
public voidinit()

    // Create a layout manager, and save a reference to it for future use.
    // This CardLayout leaves 10 pixels margins around the component.
    final CardLayout cardlayout = new CardLayout(10, 10);
    // Specify the layout manager for the applet
    this.setLayout(cardlayout);
    for(int i = 1; i <= 9; i++) {
      Button b = new Button("Button #" + i);
      ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {  // When button is clicked
          cardlayout.next(CardLayoutExample.this);    // display the next one.
        }
      };
      b.addActionListener(listener);
      this.add("Button" + i, b);   // Specify a name for each component
    }