/*
* Hamsam - Instant Messaging API
* Copyright (C) 2003 Raghu K
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package gui;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import gui.tools.PropertiesManager;
import gui.action.QuitAppli;
import gui.action.CloseSession;
import gui.action.SetOptions;
import gui.action.LaunchHelp;
import gui.action.AboutHamsam;
/**
* <p>Titre : Hamsam Project</p>
* <p>Description : Instant Messenger</p>
* <p>Copyright : Copyright (c) 2003</p>
* <p>Soci�t� : </p>
* @author Fr�d�ric DIB
* @version 0.1
*/
public class MenuBar extends JMenuBar {
private JMenu sessionMenu = null;
private JMenu optionsMenu = null;
private PropertiesManager properties = null;
public MenuBar(PropertiesManager p) {
properties = p;
this.initMenuBar();
}
/**
* Init the menu bar.
*/
private void initMenuBar() {
this.initOptionsMenu();
this.initSessionMenu();
this.add(sessionMenu);
this.add(optionsMenu);
}
/**
* Init the session menu.
*/
private void initSessionMenu() {
sessionMenu = new JMenu(this.properties.getValue("sessionMenu"));
JMenuItem openSession = new JMenuItem(properties.getValue("openSession"));
JMenuItem closeSession = new JMenuItem(properties.getValue("closeSession"));
JMenuItem exit = new JMenuItem(properties.getValue("exit"));
exit.addActionListener(new QuitAppli());
closeSession.addActionListener(new CloseSession());
//this.sessionMenu.add(openSession);
this.sessionMenu.add(closeSession);
this.sessionMenu.add(exit);
this.sessionMenu.setMnemonic(this.sessionMenu.getText().charAt(0));
}
/**
* Init the option menu.
*/
private void initOptionsMenu() {
optionsMenu = new JMenu(this.properties.getValue("optionsMenu"));
JMenuItem options = new JMenuItem(properties.getValue("options"));
JMenuItem help = new JMenuItem(properties.getValue("help"));
JMenuItem about = new JMenuItem(properties.getValue("about"));
options.addActionListener(new SetOptions(this.properties, MainFrame.myRef));
help.addActionListener(new LaunchHelp());
about.addActionListener(new AboutHamsam());
this.optionsMenu.add(options);
this.optionsMenu.add(help);
this.optionsMenu.add(about);
this.optionsMenu.setMnemonic(this.optionsMenu.getText().charAt(0));
}
}