/Users/lyon/j4p/src/ip/gui/frames/EventTesterFrame.java
|
1 package ip.gui.frames;
2
3 import java.awt.*;
4 import java.awt.event.ActionEvent;
5
6 public class EventTesterFrame extends
7 ShortCutFrame {
8 Menu m1 = getMenu("Event Menu");
9 MenuItem item1_mi = addMenuItem(m1, "[1] one");
10 MenuItem item2_mi = addMenuItem(m1, "[T-2] two");
11
12 Menu hierarchicMenu = getMenu("Hierarchic Menu");
13 MenuItem itemH1_mi = addMenuItem(hierarchicMenu, "[E-3] three");
14 MenuItem itemH2_mi = addMenuItem(hierarchicMenu, "[E-T-4] four");
15
16 public static void main(String args[]) {
17 EventTesterFrame et = new EventTesterFrame("Event Tester");
18 }
19
20 public EventTesterFrame(String title) {
21 super(title);
22 initMenuBar();
23 setVisible(true);
24 }
25
26 public void initMenuBar() {
27 MenuBar mb = new MenuBar();
28 m1.add(hierarchicMenu);
29 mb.add(m1);
30 setMenuBar(mb);
31 }
32
33 public void paint(Graphics g) {
34 g.drawString("event tester", 50, 50);
35 }
36
37 public void actionPerformed(ActionEvent e) {
38 if (match(e, item1_mi))
39 System.out.println("Item 1!");
40 else if (match(e, item2_mi))
41 System.out.println("Item 2!");
42 else if (match(e, itemH1_mi))
43 System.out.println("Item h1!");
44 else if (match(e, itemH2_mi))
45 System.out.println("Item h2!");
46 super.actionPerformed(e);
47
48 }
49 }