AWT User Interface Components 9.29
35. button2.addActionListener(obj);
36. buttons.add(button1);
37. buttons.add(button2);
38. Panel card1 = new Panel();
39. card1.add(new Label(“Capital of India: New Delhi”));
40. Panel card2 = new Panel();
41. card2.add(new TextField(“Enter Capital of USA “));
42. cl = new CardLayout();
43. cards = new Panel();
44. cards.setLayout(cl);
45. cards.add(card1, INDIA);
46. cards.add(card2, UNITEDSTATES);
47. setLayout(new BorderLayout());
48. add(cards, BorderLayout.NORTH);
49. add(buttons, BorderLayout.SOUTH);
50. }
51. class HandleEvent implements ActionListener{
52. public void actionPerformed(ActionEvent e) {
a. Object src = e.getSource();
b. if (src == button1)
i. cl.show(cards,INDIA ); ...