1 18 19 package sync4j.syncclient.demo; 20 21 import java.awt.Menu ; 22 import java.awt.MenuBar ; 23 import java.awt.MenuItem ; 24 import java.awt.event.ActionEvent ; 25 import java.awt.event.ActionListener ; 26 27 34 public class DemoMenuBar 35 extends MenuBar 36 implements ActionListener , ConfigurationParameters { 37 38 40 42 private MainWindow mw = null ; 46 private About ppcAbout = null ; 47 48 private Language ln = new Language() ; 49 50 52 57 public DemoMenuBar(MainWindow mw) { 58 59 MenuItem mi = null; 60 Menu menuFile = null; 61 Menu menuEdit = null; 62 Menu menuView = null; 63 Menu menuHelp = null; 64 65 this.mw = mw; 66 67 menuFile = new Menu (ln.getString("file")); 71 72 menuFile.add(mi = new MenuItem (ln.getString ("synchronize" )) ) ; 73 mi.addActionListener(this); 74 menuFile.add(mi = new MenuItem (ln.getString ("configure" )) ) ; 75 mi.addActionListener(this); 76 menuFile.addSeparator(); 77 menuFile.add(mi = new MenuItem (ln.getString ("exit" )) ) ; 78 mi.addActionListener(this); 79 80 menuEdit = new Menu (ln.getString("edit")); 84 menuEdit.add(mi = new MenuItem (ln.getString ("new_contact" )) ); 85 mi.addActionListener(this); 86 menuEdit.add(mi = new MenuItem (ln.getString ("new_calendar" )) ); 87 mi.addActionListener(this); 88 89 menuView = new Menu (ln.getString("view")); 93 menuView.add(mi = new MenuItem (ln.getString ("contact_list" )) ); 94 mi.addActionListener(this); 95 menuView.add(mi = new MenuItem (ln.getString ("calendar_list" )) ); 96 mi.addActionListener(this); 97 98 menuHelp = new Menu (ln.getString ("help" )) ; 102 menuHelp.add(mi = new MenuItem (ln.getString ("about" ))) ; 103 mi.addActionListener(this); 104 105 ppcAbout = new About(mw); 109 110 add (menuFile ) ; 111 add (menuEdit ) ; 112 add (menuView ) ; 113 add (menuHelp ) ; 114 } 115 116 121 public void actionPerformed(ActionEvent evt) { 122 123 String item = evt.getActionCommand(); 124 125 if (item.equals(ln.getString("exit"))) { 126 mw.exit(); 127 } else if (item.equals (ln.getString ("configure" ))) { 128 mw.show(KEY_CONFIG); 129 } else if (item.equals (ln.getString ("contact_list" ))) { 130 mw.show(KEY_CONTACTLIST); 131 } else if (item.equals (ln.getString ("new_contact" ))) { 132 mw.show(KEY_CONTACTNEW); 133 } else if (item.equals (ln.getString ("calendar_list" ))) { 134 mw.show(KEY_CALENDARLIST); 135 } else if (item.equals (ln.getString ("new_calendar" ))) { 136 mw.show(KEY_CALENDARNEW); 137 } else if (item.equals (ln.getString ("synchronize" ))) { 138 mw.show(KEY_SYNC); 139 } else if (item.equals (ln.getString ("about" ))) { 140 mw.setEnabled(false); 141 ppcAbout.show(); 142 } 143 } 144 145 147 } | Popular Tags |