Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.gui.components.MenuBar.java

Here you can find all the information about the file org.dgpf.gui.components.MenuBar.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2006 Universitaet Kassel
 *
 * E-Mail           : mirko.dietrich@hrz.uni-kassel.de
 * Original Filename: org.dgpf.gui.DGPFMenuBar.java
 *
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *
 * Warranty         : This software is provided "as is" 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.
 */


package org.dgpf.gui.components;

import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import org.dgpf.gui.Frame;
import org.dgpf.gui.utils.LanguageSwitcher;

/**
 * This class represents a menu bar.
 */

public class MenuBar extends JMenuBar
  {

  /**
   * The serial version UID.
   */

  private static final long serialVersionUID = 1L;

  /**
   * @param p_frame
   *          DGPF frame.
   */

  public MenuBar(Frame p_frame)
    {
    /* File menu */
    JMenu l_file_menu = new JMenu(LanguageSwitcher.getString("mb_file"));
    l_file_menu.setMnemonic(LanguageSwitcher.getChar("mb_file_mnemo"));
    /* connect to host entry */
    l_file_menu.add(this.createMenuItem(LanguageSwitcher
        .getString("mb_connect_to_host_frame"),
        "mb_connect_to_host_frame", LanguageSwitcher
            .getChar("mb_connect_to_host_frame"), p_frame, true,
        "org/dgpf/gui/resources/bitmaps/con_host.png"));
    /* connect to host list entry */
    l_file_menu.add(this.createMenuItem(LanguageSwitcher
        .getString("mb_connect_to_hosts"), "mb_connect_to_hosts",
        LanguageSwitcher.getChar("mb_connect_to_hosts_mnemo"), p_frame,
        true, "org/dgpf/gui/resources/bitmaps/con_hosts.png"));
    /* start jar on connected hosts entry */
    l_file_menu.add(this.createMenuItem(LanguageSwitcher
        .getString("mb_start_jar"), "start_jar", LanguageSwitcher
        .getChar("mb_start_jar_mnemo"), p_frame, true,
        "org/dgpf/gui/resources/bitmaps/start_small.png"));
    l_file_menu.addSeparator();
    /* exit entry */
    l_file_menu.add(this.createMenuItem(LanguageSwitcher
        .getString("mb_exit"), "exit", LanguageSwitcher
        .getChar("mb_exit_mnemo"), p_frame, true,
        "org/dgpf/gui/resources/bitmaps/quit.png"));
    add(l_file_menu);

    /* Edit menu */
    JMenu l_edit_menu = new JMenu(LanguageSwitcher.getString("mb_edit"));
    l_edit_menu.setMnemonic(LanguageSwitcher.getChar("mb_edit_mnemo"));
    /* hostlist editor entry */
    l_edit_menu.add(this.createMenuItem(LanguageSwitcher
        .getString("mb_hostlist_editor"), "hostlist_editor",
        LanguageSwitcher.getChar("mb_hostlist_editor_mnemo"), p_frame, true,
        "org/dgpf/gui/resources/bitmaps/hostlist.png"));
    /* settings entry */
    l_edit_menu.add(this.createMenuItem(LanguageSwitcher
        .getString("mb_settings"), "settings", LanguageSwitcher
        .getChar("mb_settings_mnemo"), p_frame, true,
        "org/dgpf/gui/resources/bitmaps/preferences.png"));
    add(l_edit_menu);

    /* Help menu */
    JMenu l_help_menu = new JMenu(LanguageSwitcher.getString("mb_help"));
    l_help_menu.setMnemonic(LanguageSwitcher.getChar("mb_help_mnemo"));
    /* hp entry */
    l_help_menu.add(this.createMenuItem(LanguageSwitcher
        .getString("mb_homepage"), "homepage", LanguageSwitcher
        .getChar("mb_homepage_mnemo"), p_frame, true,
        "org/dgpf/gui/resources/bitmaps/link_small.png"));
    /* documents entry */
    l_help_menu.add(this.createMenuItem(LanguageSwitcher
        .getString("mb_documents"), "docs", LanguageSwitcher
        .getChar("mb_documents"), p_frame, true, null));
    /* javadocs entry */
    l_help_menu.add(this.createMenuItem(LanguageSwitcher
        .getString("mb_javadocs"), "javadocs", LanguageSwitcher
        .getChar("mb_javadocs_mnemo"), p_frame, true, null));
    /* join entry */
    l_help_menu.add(this.createMenuItem(LanguageSwitcher
        .getString("mb_join"), "join", LanguageSwitcher
        .getChar("mb_join_mnemo"), p_frame, true, null));
    l_help_menu.addSeparator();
    /* about entry */
    l_help_menu.add(this.createMenuItem(LanguageSwitcher
        .getString("mb_about"), "about", LanguageSwitcher
        .getChar("mb_about_mnemo"), p_frame, true, null));
    add(l_help_menu);
    }

  /**
   * Creates a menu item.
   * 
   * @param p_caption
   *          for menu item.
   * @param p_cmd
   *          action command name.
   * @param p_mnemonic
   *          mnemonic to set.
   * @param p_actionListener
   *          for this item.
   * @param p_visible
   *          status of visibiliy.
   * @param p_icon
   *          is the name of the icon. If <code>null</code> is specified.
   *          the entry will come without icon.
   * @return the created <code>JMenuItem</code>.
   */

  private JMenuItem createMenuItem(String p_caption, String p_cmd,
      char p_mnemonic, ActionListener p_actionListener, boolean p_visible,
      String p_icon)
    {
    JMenuItem l_item = new JMenuItem(p_caption);
    if(p_icon != null)
      {
      try
        {
        l_item
            .setIcon(new ImageIcon(ClassLoader.getSystemResource(p_icon)));
        }
      catch(NullPointerException e)
        {
        System.err.println("Error: Icon not found: " + p_icon);
        }
      }
    l_item.setMnemonic(p_mnemonic);
    l_item.setActionCommand(p_cmd);
    l_item.setEnabled(p_visible);
    l_item.addActionListener(p_actionListener);
    return l_item;
    }
  }

File Information:

file name:MenuBar.java
package:org.dgpf.gui.components
qualified name:org.dgpf.gui.components.MenuBar.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/gui/components/MenuBar.java
size:5.891 KB (6033 B)
uploaded: 2015-07-22 04:10:58 GMT+0000
last update: 2006-09-24 23:47:04 GMT+0000
last access: 2017-11-19 05:01:04 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2015-07-22 04:10:53 GMT+0000 served at 2017-11-19 05:01:04 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo