KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > syncclient > ipod > MenuBar


1 /**
2  * Copyright (C) 2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package sync4j.syncclient.ipod;
19
20 import java.awt.Font JavaDoc;
21 import java.awt.Color JavaDoc;
22 import java.awt.event.ActionEvent JavaDoc;
23 import java.awt.event.ActionListener JavaDoc;
24 import javax.swing.JMenuBar JavaDoc;
25 import javax.swing.JMenu JavaDoc;
26 import javax.swing.JMenuItem JavaDoc;
27
28 import sync4j.syncclient.ipod.utils.Language;
29 import sync4j.syncclient.ipod.panels.*;
30
31 /**
32  * The menu bar for this GUI.
33  *
34  * @author Luigia Fassina @ Funambol
35  * @version $$
36  */

37 public class MenuBar extends JMenuBar JavaDoc implements ActionListener JavaDoc {
38
39     // ------------------------------------------------------------ Private Data
40
private Font JavaDoc font = new Font JavaDoc("Microsoft Sans Serif", 0, 12);
41     private JMenu JavaDoc menu = null;
42     private JMenuItem JavaDoc menuItem = null;
43     private MainWindow mainWindow = null;
44     private Color JavaDoc color = new Color JavaDoc(236,233,216);
45     // ---------------------------------------------------------- Public Methods
46
public MenuBar(MainWindow mainWindow) {
47
48         this.mainWindow = mainWindow;
49
50         setBackground(color);
51
52         //
53
// File Menu
54
//
55
menu = new JMenu JavaDoc(Language.getMessage(Language.MENU_FILE));
56         menu.setBackground(color);
57         menu.setFont(font);
58
59         menuItem = new JMenuItem JavaDoc(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 JavaDoc(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         //
77
// Edit Menu
78
//
79
menu = new JMenu JavaDoc(Language.getMessage(Language.MENU_EDIT));
80         menu.setBackground(color);
81         menu.setFont(font);
82
83         menuItem = new JMenuItem JavaDoc(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 JavaDoc(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         //
99
// Help Menu
100
//
101
menu = new JMenu JavaDoc(Language.getMessage(Language.MENU_HELP));
102         menu.setBackground(color);
103         menu.setFont(font);
104
105         menuItem = new JMenuItem JavaDoc(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 JavaDoc(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 JavaDoc 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