
9.20 Graphics Using AWT Controls
21. b = new Button(“Click for Dialog Box”);
22. add(b);
23. d = new Dialog(this, “Dialog Box Demo” , false);
24. d.setSize(300, 300);
25. d.setLocation(400,100);
26. db = new Button(“Click to Close Dialog Box”);
27. d.add(db);
28. HandleEvent evt = new HandleEvent();
29. b.addActionListener(evt);
30. db.addActionListener(evt);
31. }
32. class HandleEvent implements ActionListener{
33. public void actionPerformed(ActionEvent e) {
34. Object obj = e.getSource();
35. if (obj == b)
36. d.setVisible(true);
37. else
38. if(obj == db)
39. d.setVisible(false);
40. }
41. }
42. }
9.3.10 Menubars and Menus
Menus in Jav