1 18 package sync4j.syncclient.ipod; 19 20 import java.awt.Font ; 21 import java.awt.Color ; 22 import java.awt.event.ActionEvent ; 23 import java.awt.event.ActionListener ; 24 import javax.swing.JMenuBar ; 25 import javax.swing.JMenu ; 26 import javax.swing.JMenuItem ; 27 28 import sync4j.syncclient.ipod.utils.Language; 29 import sync4j.syncclient.ipod.panels.*; 30 31 37 public class MenuBar extends JMenuBar implements ActionListener { 38 39 private Font font = new Font ("Microsoft Sans Serif", 0, 12); 41 private JMenu menu = null; 42 private JMenuItem menuItem = null; 43 private MainWindow mainWindow = null; 44 private Color color = new Color (236,233,216); 45 public MenuBar(MainWindow mainWindow) { 47 48 this.mainWindow = mainWindow; 49 50 setBackground(color); 51 52 menu = new JMenu (Language.getMessage(Language.MENU_FILE)); 56 menu.setBackground(color); 57 menu.setFont(font); 58 59 menuItem = new JMenuItem (Language.getMessage(Language.MENU_FILE_SYNC)); 60 menuItem.setFont(font); 61 menuItem.setBackground(Color.WHITE); 62 menuItem.setActionCommand("SYNCHRONIZATION"); 63 menuItem.addActionListener(this); 64 menu.add(menuItem); 65 66 menu.addSeparator(); 67 68 menuItem = new JMenuItem (Language.getMessage(Language.MENU_FILE_EXIT)); 69 menuItem.setFont(font); 70 menuItem.setBackground(Color.WHITE); 71 menuItem.setActionCommand("EXIT"); 72 menuItem.addActionListener(this); 73 menu.add(menuItem); 74 add(menu); 75 76 menu = new JMenu (Language.getMessage(Language.MENU_EDIT)); 80 menu.setBackground(color); 81 menu.setFont(font); 82 83 menuItem = new JMenuItem (Language.getMessage(Language.MENU_EDIT_COMMUNICATION_SET)); 84 menuItem.setBackground(Color.WHITE); 85 menuItem.setFont(font); 86 menuItem.setActionCommand("COMMUNICATIONSET"); 87 menuItem.addActionListener(this); 88 menu.add(menuItem); 89 90 menuItem = new JMenuItem (Language.getMessage(Language.MENU_EDIT_SYNC_SET)); 91 menuItem.setBackground(Color.WHITE); 92 menuItem.setFont(font); 93 menuItem.setActionCommand("SYNCSET"); 94 menuItem.addActionListener(this); 95 menu.add(menuItem); 96 add(menu); 97 98 menu = new JMenu (Language.getMessage(Language.MENU_HELP)); 102 menu.setBackground(color); 103 menu.setFont(font); 104 105 menuItem = new JMenuItem (Language.getMessage(Language.MENU_HELP_LOG)); 106 menuItem.setBackground(Color.WHITE); 107 menuItem.setFont(font); 108 menuItem.setActionCommand("VIEWLOG"); 109 menuItem.addActionListener(this); 110 menu.add(menuItem); 111 112 menu.addSeparator(); 113 114 menuItem = new JMenuItem (Language.getMessage(Language.MENU_HELP_ABOUT)); 115 menuItem.setBackground(Color.WHITE); 116 menuItem.setFont(font); 117 menuItem.setActionCommand("ABOUT"); 118 menuItem.addActionListener(this); 119 menu.add(menuItem); 120 121 add(menu); 122 123 } 124 125 public void actionPerformed(ActionEvent e) { 126 if (e.getActionCommand().equals("SYNCHRONIZATION")) { 127 mainWindow.runSynchronization(); 128 } else if(e.getActionCommand().equals("COMMUNICATIONSET")) { 129 CommunicationSetPanel c = new CommunicationSetPanel(mainWindow,true); 130 c.show(); 131 } else if(e.getActionCommand().equals("SYNCSET")) { 132 SyncSetPanel ssp = new SyncSetPanel(mainWindow,true); 133 ssp.show(); 134 } else if(e.getActionCommand().equals("VIEWLOG")) { 135 LogPanel lp = new LogPanel(mainWindow,true); 136 lp.show(); 137 } else if(e.getActionCommand().equals("ABOUT")) { 138 AboutPanel ap = new AboutPanel(mainWindow,true); 139 ap.show(); 140 } else if(e.getActionCommand().equals("EXIT")) { 141 mainWindow.exit(); 142 } 143 144 } 145 } | Popular Tags |