FileDocCategorySizeDatePackage
CardLayDemo1.javaAPI DocExample1025Thu Dec 31 17:10:32 GMT 1998None

CardLayDemo1

public class CardLayDemo1 extends Applet
Simpler CardLayout demo: cycles through some labels.
author
Ian Darwin
version
$Id: CardLayDemo1.java,v 1.2 1998/12/31 22:10:33 ian Exp $

Fields Summary
CardLayout
cardlay
Panel
panel
Button
b1
int
cardno
final int
NCARDS
String[]
labels
Constructors Summary
Methods Summary
public voidinit()


	   

		panel = new Panel();
		cardlay = new CardLayout();
		b1 = new Button("Next");
		b1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				if (++cardno >= NCARDS)
					cardno = 0;
				cardlay.show(panel, labels[cardno]);
			}
		});
		labels[0] = "Card One";
		labels[1] = "Card Two";
		labels[2] = "Card Three";
		labels[3] = "Card Four";

		panel.setLayout(cardlay);
		for (int i=0; i<NCARDS; i++)
			panel.add(labels[i], new Label(labels[i]));
		cardlay.show(panel, labels[0]);

		setLayout(new BorderLayout());
		add("Center", panel);
		add("South", b1);