/Users/lyon/j4p/src/addBk/addressBook/AddressBookMenu.java
|
1 package addBk.addressBook;
2
3 //AddressBookMenu.java
4
5
6 import java.awt.Menu;
7 import java.awt.MenuBar;
8 import java.awt.MenuItem;
9 import java.awt.event.ActionEvent;
10 import java.awt.event.ActionListener;
11
12
13 public class AddressBookMenu
14 extends MenuBar
15 implements ActionListener {
16
17 Menu fileMenu =
18 new Menu("File");
19 MenuOpen openObject =
20 new MenuOpen();
21 MenuSave saveObject =
22 new MenuSave();
23 MenuMerge mergeCSV =
24 new MenuMerge();
25 MenuExport exportCSV =
26 new MenuExport();
27 MenuExit systemExit =
28 new MenuExit();
29
30 public void
31 actionPerformed(ActionEvent e) {
32 ((Runnable)
33 e.getSource()).run();
34 }
35
36 AddressBookMenu() {
37 fileMenu.add(openObject);
38 fileMenu.add(saveObject);
39 fileMenu.add(mergeCSV);
40 fileMenu.add(exportCSV);
41 fileMenu.add(systemExit);
42 add(fileMenu);
43
44 openObject.addActionListener(this);
45 saveObject.addActionListener(this);
46 mergeCSV.addActionListener(this);
47 exportCSV.addActionListener(this);
48 systemExit.addActionListener(this);
49 }
50
51 public class MenuOpen extends MenuItem
52 implements Runnable {
53 MenuOpen() {
54 super("Open");
55 }
56
57 public void run() {
58 System.out.println("Run Open Object");
59 AddressBookMediator display =
60 new AddressBookMediator();
61 display.dbOpen();
62 }
63 }
64
65 public class MenuSave extends MenuItem
66 implements Runnable {
67 MenuSave() {
68 super("Save");
69 }
70
71 public void run() {
72 System.out.println(
73 "Run Close Object");
74 AddressBookMediator display =
75 new AddressBookMediator();
76 display.dbSave();
77 }
78 }
79
80 public class MenuMerge extends MenuItem
81 implements Runnable {
82 MenuMerge() {
83 super("Merge CSV");
84 }
85
86 public void run() {
87 System.out.println("Run Merge CSV");
88 AddressBookMediator display =
89 new AddressBookMediator();
90 display.dbMerge();
91 }
92 }
93
94 public class MenuExport extends MenuItem
95 implements Runnable {
96 MenuExport() {
97 super("Export CSV");
98 }
99
100 public void run() {
101 System.out.println("Run Export CSV");
102 AddressBookMediator display =
103 new AddressBookMediator();
104 display.dbExport();
105 }
106 }
107
108 public class MenuExit extends MenuItem
109 implements Runnable {
110 MenuExit() {
111 super("Exit");
112 }
113
114 public void run() {
115 System.out.println("Run exit");
116 System.exit(0);
117 }
118 }
119
120
121 }