// Eksempel på brug af CardLayout * 2000-12-14 // Start programmet og tryk retur for at skifte mellem de tre `cards' import java.awt.*; import java.io.*; public class CardLayoutTest { public static void main(String[] args) throws IOException { Frame f = new Frame("CardlayoutTest"); CardLayout cl = new CardLayout(); f.setLayout(cl); Button br = new Button("Kort 1"); br.setBackground(Color.red); f.add(br, "r"); Button bg = new Button("Kort 2"); bg.setBackground(Color.green); f.add(bg, "g"); Button bb = new Button("Kort 3"); bb.setBackground(Color.blue); f.add(bb, "b"); cl.show(f, "r"); // Skift til et navngivet kort f.pack(); f.show(); for (;;) { System.in.read(); // Vent til der trykkes Enter cl.next(f); // Skift til næste kort (cyklisk) } } }