Example usage for javax.swing JMenuBar add

List of usage examples for javax.swing JMenuBar add

Introduction

In this page you can find the example usage for javax.swing JMenuBar add.

Prototype

public JMenu add(JMenu c) 

Source Link

Document

Appends the specified menu to the end of the menu bar.

Usage

From source file:org.jcurl.demo.tactics.TacticsApp.java

private JMenuBar createMenu() {
    final JMenuBar bar = new JMenuBar();
    {//www . j  a va2s.c  o m
        final JMenu menu = bar.add(new JMenu("File"));
        menu.setMnemonic('F');
        menu.add(this.newMI("New", null, 'N', -1, this, "cmdNew"));
        menu.add(this.newMI("Open", null, 'O', KeyEvent.VK_O, this, "cmdOpen"));
        menu.addSeparator();
        menu.add(this.newMI("Export Png", null, 'P', KeyEvent.VK_E, this, "cmdExportPng"));
        menu.addSeparator();
        menu.add(this.newMI("Save", null, 'S', KeyEvent.VK_S, this, "cmdSave"));
        menu.add(this.newMI("Save As", null, 'A', -1, this, "cmdSaveAs"));
        menu.addSeparator();
        menu.add(this.newMI("Exit", null, 'x', -1, this, "cmdExit"));
    }
    {
        final JMenu menu = bar.add(new JMenu("View"));
        menu.setMnemonic('V');
        menu.add(this.newMI("Zoom", null, 'z', -1, this, "cmdZoom"));
    }
    {
        final JMenu menu = bar.add(new JMenu("Play"));
        menu.setMnemonic('P');
        menu.setEnabled(false);
        // menu.add(newMI('a', -1, bStart.getAction()));
        // menu.add(newMI('P', -1, bPause.getAction()));
        // menu.add(newMI('o', -1, bStop.getAction()));
    }
    {
        final JMenu menu = bar.add(new JMenu("Help"));
        menu.setMnemonic('H');
        menu.add(this.newMI("About", null, 'a', -1, this, "cmdAbout"));
    }
    return bar;
}

From source file:org.jwebgenerator.views.WorkSpaceWindow.java

/**
 * @return/*  ww  w  . j ava 2  s .  c  om*/
 */
private JMenuBar createMenuBar() {

    final JMenuBar menuBar = new JMenuBar();
    final JMenu fileMenu = new JMenu("Fichier");

    final JMenuItem exitMenu = new JMenuItem("Quitter");
    fileMenu.add(exitMenu);
    exitMenu.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            System.exit(0);
        }
    });

    menuBar.add(fileMenu);
    return menuBar;
}

From source file:org.kuali.test.creator.TestCreator.java

private void createMenuBar() {
    JMenuBar mainMenu = new JMenuBar();

    JMenuItem menu = new JMenu();
    menu.setMnemonic('f');
    menu.setText("File");

    JMenuItem m = new JMenuItem("Reload Configuration");
    m.addActionListener(new ActionListener() {
        @Override/*  w w  w . j a v a2 s  . c o m*/
        public void actionPerformed(ActionEvent evt) {
            handleReloadConfiguation(evt);
        }
    });

    menu.add(m);

    m = new JMenuItem("Schedule Tests...");
    m.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            handleScheduleTests(evt);
        }
    });

    menu.add(m);

    menu.add(new JSeparator());

    saveConfigurationMenuItem = new JMenuItem("Save Repository Configuration");
    saveConfigurationMenuItem.setEnabled(false);

    saveConfigurationMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            testRepositoryTree.saveConfiguration();
            saveConfigurationButton.setEnabled(false);
            saveConfigurationMenuItem.setEnabled(false);
        }
    });

    menu.add(saveConfigurationMenuItem);

    JMenuItem backupRepositoryMenuItem = new JMenuItem("Backup Repository");

    backupRepositoryMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            handleBackupRepository();
        }
    });

    menu.add(backupRepositoryMenuItem);

    menu.add(new JSeparator());

    createTestMenuItem = new JMenuItem("Create Test");

    createTestMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            handleCreateTest(null);
        }
    });

    menu.add(createTestMenuItem);

    menu.add(new JSeparator());

    JMenuItem setup = new JMenu("Setup");

    m = new JMenuItem("Add Platform");
    m.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            handleAddPlatform(evt);
        }
    });
    setup.add(m);

    m = new JMenuItem("Add Database Connection");
    m.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            handleAddDatabaseConnection(evt);
        }
    });
    setup.add(m);

    m = new JMenuItem("Add Web Service");

    m.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            handleAddWebService(evt);
        }
    });

    setup.add(m);

    m = new JMenuItem("Add JMX Connection");

    m.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            handleAddJmxConnection(evt);
        }
    });

    setup.add(m);

    setup.add(new JSeparator());

    m = new JMenuItem("Parameters requiring encryption");
    m.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            handleParametersRequiringEncryptionSetup();
        }
    });

    setup.add(m);

    m = new JMenuItem("Auto replace parameters");
    m.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            handleAutoReplaceParameterSetup();
        }
    });

    setup.add(m);

    setup.add(new JSeparator());

    m = new JMenuItem("Email Setup");
    m.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            handleEmailSetup(evt);
        }
    });

    setup.add(m);

    menu.add(setup);

    menu.add(new JSeparator());

    m = new JMenuItem("Exit");
    m.setMnemonic('x');
    m.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            exitApplication.doClick();
        }
    });

    menu.add(m);

    mainMenu.add(menu);

    menu = new JMenu("Help");
    menu.setMnemonic('h');

    m = new JMenuItem("Contents");
    m.setMnemonic('c');
    menu.add(m);
    m.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            showHelp(evt);
        }
    });

    m = new JMenuItem("About");
    m.setMnemonic('a');
    menu.add(m);

    m.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            showHelpAbout();
        }
    });

    mainMenu.add(menu);

    setJMenuBar(mainMenu);
}

From source file:org.kuali.test.ui.components.panels.BaseCreateTestPanel.java

/**
 *
 * @return//  w  w  w.j a v  a  2  s .c om
 */
protected JMenuBar createOperationPanel() {
    JMenuBar retval = new JMenuBar();

    JMenu menu = new JMenu(Constants.OPERATION_ACTION) {
        @Override
        public Insets getInsets() {
            return new Insets(1, 5, 1, 200);
        }
    };

    menu.setMnemonic('o');

    cancelTest = new JMenuItem(Constants.CANCEL_TEST_ACTION);
    cancelTest.setMnemonic('c');

    saveTest = new JMenuItem(Constants.SAVE_TEST_ACTION);

    createCheckpoint = new JMenuItem(Constants.CREATE_CHECKPOINT_ACTION);
    createComment = new JMenuItem(Constants.CREATE_COMMENT_ACTION);
    createParameter = new JMenuItem(Constants.CREATE_PARAMETER_ACTION);

    viewCheckpoints = new JMenuItem(Constants.VIEW_CHECKPOINTS_ACTION);
    viewComments = new JMenuItem(Constants.VIEW_COMMENTS_ACTION);
    viewParameters = new JMenuItem(Constants.VIEW_PARAMETERS_ACTION);

    menu.add(cancelTest);
    menu.add(saveTest);

    menu.addSeparator();

    menu.add(createCheckpoint);
    menu.add(createComment);

    if (isParameterOperationRequired()) {
        menu.add(createParameter);
    }

    menu.addSeparator();

    menu.add(viewCheckpoints);
    menu.add(viewComments);
    if (isParameterOperationRequired()) {
        menu.add(viewParameters);
    }

    cancelTest.addActionListener(this);
    saveTest.addActionListener(this);
    createCheckpoint.addActionListener(this);
    createComment.addActionListener(this);
    if (isParameterOperationRequired()) {
        createParameter.addActionListener(this);
    }
    viewCheckpoints.addActionListener(this);
    viewComments.addActionListener(this);
    if (isParameterOperationRequired()) {
        viewParameters.addActionListener(this);
    }

    retval.add(menu);

    StringBuilder txt = new StringBuilder(128);

    txt.append("<html><span style='font-weight: 700;'>Platform: </span><span style='color: ");
    txt.append(Constants.COLOR_DARK_BLUE);
    txt.append(";  font-weight: normal;'>");
    txt.append(platform.getName());
    txt.append(
            "</span><span style='font-weight: 700; padding-left: 30px;'>, Test Type: </span><span style='color: ");
    txt.append(Constants.COLOR_DARK_BLUE);
    txt.append(";  font-weight: normal;'>");
    txt.append(testHeader.getTestType().toString());
    txt.append(
            "</span><span style='font-weight: 700; padding-left: 30px;'>, Test Name: </span><span style='color: ");
    txt.append(Constants.COLOR_DARK_BLUE);
    txt.append("; font-weight: normal;'>");
    txt.append(testHeader.getTestName());
    txt.append("</span></html>");

    retval.add(new JLabel(txt.toString()));

    return retval;
}

From source file:org.languagetool.gui.Main.java

private JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu(getLabel("guiMenuFile"));
    fileMenu.setMnemonic(getMnemonic("guiMenuFile"));
    JMenu editMenu = new JMenu(getLabel("guiMenuEdit"));
    editMenu.setMnemonic(getMnemonic("guiMenuEdit"));
    JMenu grammarMenu = new JMenu(getLabel("guiMenuGrammar"));
    grammarMenu.setMnemonic(getMnemonic("guiMenuGrammar"));
    JMenu helpMenu = new JMenu(getLabel("guiMenuHelp"));
    helpMenu.setMnemonic(getMnemonic("guiMenuHelp"));

    fileMenu.add(openAction);// w w  w .j  av a  2 s . c o  m
    fileMenu.add(saveAction);
    fileMenu.add(saveAsAction);
    recentFilesMenu = new JMenu(getLabel("guiMenuRecentFiles"));
    recentFilesMenu.setMnemonic(getMnemonic("guiMenuRecentFiles"));
    fileMenu.add(recentFilesMenu);
    updateRecentFilesMenu();
    fileMenu.addSeparator();
    fileMenu.add(new HideAction());
    fileMenu.addSeparator();
    fileMenu.add(new QuitAction());

    grammarMenu.add(checkAction);
    JCheckBoxMenuItem item = new JCheckBoxMenuItem(autoCheckAction);
    grammarMenu.add(item);
    JCheckBoxMenuItem showResult = new JCheckBoxMenuItem(showResultAction);
    grammarMenu.add(showResult);
    grammarMenu.add(new CheckClipboardAction());
    grammarMenu.add(new TagTextAction());
    grammarMenu.add(new AddRulesAction());
    grammarMenu.add(new OptionsAction());
    grammarMenu.add(new SelectFontAction());
    JMenu lafMenu = new JMenu(messages.getString("guiLookAndFeelMenu"));
    UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
    ButtonGroup buttonGroup = new ButtonGroup();
    for (UIManager.LookAndFeelInfo laf : lafInfo) {
        if (!"Nimbus".equals(laf.getName())) {
            continue;
        }
        addLookAndFeelMenuItem(lafMenu, laf, buttonGroup);
    }
    for (UIManager.LookAndFeelInfo laf : lafInfo) {
        if ("Nimbus".equals(laf.getName())) {
            continue;
        }
        addLookAndFeelMenuItem(lafMenu, laf, buttonGroup);
    }
    grammarMenu.add(lafMenu);

    helpMenu.add(new AboutAction());

    undoRedo.undoAction.putValue(Action.NAME, getLabel("guiMenuUndo"));
    undoRedo.undoAction.putValue(Action.MNEMONIC_KEY, getMnemonic("guiMenuUndo"));
    undoRedo.redoAction.putValue(Action.NAME, getLabel("guiMenuRedo"));
    undoRedo.redoAction.putValue(Action.MNEMONIC_KEY, getMnemonic("guiMenuRedo"));

    editMenu.add(undoRedo.undoAction);
    editMenu.add(undoRedo.redoAction);
    editMenu.addSeparator();

    Action cutAction = new DefaultEditorKit.CutAction();
    cutAction.putValue(Action.SMALL_ICON, getImageIcon("sc_cut.png"));
    cutAction.putValue(Action.LARGE_ICON_KEY, getImageIcon("lc_cut.png"));
    cutAction.putValue(Action.NAME, getLabel("guiMenuCut"));
    cutAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_T);
    editMenu.add(cutAction);

    Action copyAction = new DefaultEditorKit.CopyAction();
    copyAction.putValue(Action.SMALL_ICON, getImageIcon("sc_copy.png"));
    copyAction.putValue(Action.LARGE_ICON_KEY, getImageIcon("lc_copy.png"));
    copyAction.putValue(Action.NAME, getLabel("guiMenuCopy"));
    copyAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_C);
    editMenu.add(copyAction);

    Action pasteAction = new DefaultEditorKit.PasteAction();
    pasteAction.putValue(Action.SMALL_ICON, getImageIcon("sc_paste.png"));
    pasteAction.putValue(Action.LARGE_ICON_KEY, getImageIcon("lc_paste.png"));
    pasteAction.putValue(Action.NAME, getLabel("guiMenuPaste"));
    pasteAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_P);
    editMenu.add(pasteAction);

    editMenu.addSeparator();

    editMenu.add(new SelectAllAction());

    menuBar.add(fileMenu);
    menuBar.add(editMenu);
    menuBar.add(grammarMenu);
    menuBar.add(helpMenu);
    return menuBar;
}

From source file:org.lnicholls.galleon.gui.MainFrame.java

public MainFrame(String version) {

    super("Galleon " + version);

    setDefaultCloseOperation(0);//ww  w .jav  a  2s . c o  m

    JMenuBar menuBar = new JMenuBar();

    menuBar.putClientProperty("jgoodies.headerStyle", HeaderStyle.BOTH);

    menuBar.putClientProperty("jgoodies.windows.borderStyle", BorderStyle.SEPARATOR);

    menuBar.putClientProperty("Plastic.borderStyle", BorderStyle.SEPARATOR);

    JMenu fileMenu = new JMenu("File");

    fileMenu.setMnemonic('F');

    fileMenu.add(new MenuAction("New App...", null, "", new Integer(KeyEvent.VK_N)) {

        public void actionPerformed(ActionEvent event) {

            new AddAppDialog(Galleon.getMainFrame()).setVisible(true);

        }

    });

    fileMenu.addSeparator();

    fileMenu.add(new MenuAction("Properties...", null, "", new Integer(KeyEvent.VK_P)) {

        public void actionPerformed(ActionEvent event) {

            new ServerDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true);

        }

    });

    /*
            
    fileMenu.add(new MenuAction("Galleon.tv Account...", null, "", new Integer(KeyEvent.VK_A)) {
            
            
            
       public void actionPerformed(ActionEvent event) {
            
    new DataDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true);
            
       }
            
            
            
    });
            
    */

    fileMenu.add(new MenuAction("Download Manager...", null, "", new Integer(KeyEvent.VK_D)) {

        public void actionPerformed(ActionEvent event) {

            new DownloadManagerDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration())
                    .setVisible(true);

        }

    });

    fileMenu.add(new MenuAction("GoBack...", null, "", new Integer(KeyEvent.VK_G)) {

        public void actionPerformed(ActionEvent event) {

            new GoBackDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true);

        }

    });

    fileMenu.add(new MenuAction("Music Player...", null, "", new Integer(KeyEvent.VK_M)) {

        public void actionPerformed(ActionEvent event) {

            new MusicPlayerDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true);

        }

    });

    fileMenu.add(new MenuAction("ToGo...", null, "", new Integer(KeyEvent.VK_T)) {

        public void actionPerformed(ActionEvent event) {

            new ToGoDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true);

        }

    });

    fileMenu.addSeparator();

    fileMenu.add(new MenuAction("Exit", null, "", new Integer(KeyEvent.VK_X)) {

        public void actionPerformed(ActionEvent event) {

            System.exit(0);

        }

    });

    menuBar.add(fileMenu);

    JMenu tutorialMenu = new JMenu("Tutorials");

    tutorialMenu.setMnemonic('T');

    tutorialMenu.putClientProperty("jgoodies.noIcons", Boolean.TRUE);

    tutorialMenu.add(new MenuAction("Properties", null, "", new Integer(KeyEvent.VK_P)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/");

            } catch (Exception ex) {

            }

        }

    });

    tutorialMenu.add(new MenuAction("Music Player", null, "", new Integer(KeyEvent.VK_M)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/");

            } catch (Exception ex) {

            }

        }

    });

    tutorialMenu.addSeparator();

    tutorialMenu.add(new MenuAction("Email", null, "", new Integer(KeyEvent.VK_E)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/");

            } catch (Exception ex) {

            }

        }

    });

    tutorialMenu.add(new MenuAction("Music", null, "", new Integer(KeyEvent.VK_U)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/");

            } catch (Exception ex) {

            }

        }

    });

    tutorialMenu.add(new MenuAction("Podcasting", null, "", new Integer(KeyEvent.VK_O)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/");

            } catch (Exception ex) {

            }

        }

    });

    tutorialMenu.add(new MenuAction("ToGo", null, "", new Integer(KeyEvent.VK_T)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/");

            } catch (Exception ex) {

            }

        }

    });

    menuBar.add(tutorialMenu);

    JMenu helpMenu = new JMenu("Help");

    helpMenu.setMnemonic('H');

    helpMenu.putClientProperty("jgoodies.noIcons", Boolean.TRUE);

    helpMenu.add(new MenuAction("Homepage", null, "", new Integer(KeyEvent.VK_H)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv");

            } catch (Exception ex) {

            }

        }

    });

    helpMenu.add(new MenuAction("Configuration", null, "", new Integer(KeyEvent.VK_C)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/view/93/52/");

            } catch (Exception ex) {

            }

        }

    });

    helpMenu.add(new MenuAction("FAQ", null, "", new Integer(KeyEvent.VK_F)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/content/section/3/47/");

            } catch (Exception ex) {

            }

        }

    });

    /*
            
    helpMenu.add(new MenuAction("TiVo Community Forum", null, "", new Integer(KeyEvent.VK_T)) {
            
            
            
       public void actionPerformed(ActionEvent event) {
            
    try {
            
       BrowserLauncher.openURL("http://www.tivocommunity.com/tivo-vb/forumdisplay.php?f=35");
            
    } catch (Exception ex) {
            
    }
            
       }
            
            
            
    });
            
    */

    helpMenu.add(new MenuAction("Galleon Forum", null, "", new Integer(KeyEvent.VK_G)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher.openURL("http://galleon.tv/component/option,com_joomlaboard/Itemid,26/");

            } catch (Exception ex) {

            }

        }

    });

    helpMenu.add(new MenuAction("File a bug", null, "", new Integer(KeyEvent.VK_B)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher
                        .openURL("http://sourceforge.net/tracker/?atid=705256&group_id=126291&func=browse");

            } catch (Exception ex) {

            }

        }

    });

    helpMenu.add(new MenuAction("Request a feature", null, "", new Integer(KeyEvent.VK_E)) {

        public void actionPerformed(ActionEvent event) {

            try {

                BrowserLauncher
                        .openURL("http://sourceforge.net/tracker/?atid=705259&group_id=126291&func=browse");

            } catch (Exception ex) {

            }

        }

    });

    helpMenu.addSeparator();

    helpMenu.add(new MenuAction("About...", null, "", new Integer(KeyEvent.VK_A)) {

        public void actionPerformed(ActionEvent event) {

            JOptionPane

                    .showMessageDialog(

                            Galleon.getMainFrame(),

                            "Galleon Version "

                                    + Tools.getVersion()

                                    + "\nJava Version "

                                    + System.getProperty("java.vm.version")

                                    + "\nPublishing Port "

                                    + Galleon.getHttpPort()

                                    + "\nApplication Port "

                                    + Galleon.getPort()

                                    + "\nhttp://galleon.tv\njavahmo@users.sourceforge.net\nCopyright \251 2005, 2006 Leon Nicholls. All Rights Reserved.",

                            "About", JOptionPane.INFORMATION_MESSAGE);

        }

    });

    menuBar.add(helpMenu);

    setJMenuBar(menuBar);

    JComponent content = createContentPane();

    setContentPane(content);

    pack();

    Dimension paneSize = getSize();

    Dimension screenSize = getToolkit().getScreenSize();

    setLocation((screenSize.width - paneSize.width) / 2, (screenSize.height - paneSize.height) / 2);

    URL url = getClass().getClassLoader().getResource("guiicon.gif");

    ImageIcon logo = new ImageIcon(url);

    if (logo != null)

        setIconImage(logo.getImage());

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {

            System.exit(0);

        }

    });

}

From source file:org.nebulaframework.ui.swing.node.NodeMainUI.java

/**
 * Setup Menu Bar// w w  w .  j a  v  a 2 s .  c o m
 * @return JMenu Bar
 */
private JMenuBar setupMenu() {
    JMenuBar menuBar = new JMenuBar();

    /* -- GridNode Menu -- */

    JMenu gridNodeMenu = new JMenu("GridNode");
    gridNodeMenu.setMnemonic(KeyEvent.VK_N);
    menuBar.add(gridNodeMenu);

    // Discover 
    JMenuItem clusterDiscoverItem = new JMenuItem("Disover and Connect Clusters");
    clusterDiscoverItem.setMnemonic(KeyEvent.VK_D);
    clusterDiscoverItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0));
    gridNodeMenu.add(clusterDiscoverItem);
    clusterDiscoverItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doDiscover(false);
            ((JCheckBoxMenuItem) getUIElement("menu.node.autodiscover")).setSelected(false);
        }
    });
    addUIElement("menu.node.discover", clusterDiscoverItem); // Add to components map

    // Auto-Discovery
    final JCheckBoxMenuItem autodiscoveryItem = new JCheckBoxMenuItem("Auto Discover");
    autodiscoveryItem.setMnemonic(KeyEvent.VK_A);
    autodiscoveryItem.setSelected(true);
    gridNodeMenu.add(autodiscoveryItem);
    autodiscoveryItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            autodiscover = autodiscoveryItem.isSelected();
        }
    });
    addUIElement("menu.node.autodiscover", autodiscoveryItem); // Add to components map

    gridNodeMenu.addSeparator();

    // Cluster-> Shutdown
    JMenuItem nodeShutdownItem = new JMenuItem("Shutdown", 'u');
    nodeShutdownItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0));
    nodeShutdownItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doShutdownNode();
        }
    });
    gridNodeMenu.add(nodeShutdownItem);
    addUIElement("menu.node.shutdown", nodeShutdownItem); // Add to components map

    /* -- Options Menu -- */
    JMenu optionsMenu = new JMenu("Options");
    optionsMenu.setMnemonic(KeyEvent.VK_O);
    menuBar.add(optionsMenu);

    // Configuration
    JMenuItem optionsConfigItem = new JMenuItem("Configuration...", 'C');
    optionsConfigItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showConfiguration();
        }
    });
    optionsMenu.add(optionsConfigItem);
    optionsConfigItem.setEnabled(false); // TODO Create Configuration Options

    /* -- Help Menu -- */
    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic(KeyEvent.VK_H);
    menuBar.add(helpMenu);

    // Help Contents
    JMenuItem helpContentsItem = new JMenuItem("Help Contents", 'H');
    helpContentsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
    helpContentsItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showHelp();
        }
    });
    helpMenu.add(helpContentsItem);

    helpMenu.addSeparator();

    JMenuItem helpAboutItem = new JMenuItem("About", 'A');
    helpAboutItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showAbout();
        }
    });
    helpMenu.add(helpAboutItem);

    return menuBar;
}

From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java

private JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu helpMenu = new JMenu("Help");
    menuBar.add(helpMenu);
    JMenuItem helpItem = new JMenuItem(ACTION_CMD_HELP);
    helpItem.addActionListener(this);
    helpItem.setActionCommand(ACTION_CMD_HELP);
    helpMenu.add(helpItem);/*from w w  w.j  ava  2 s.  c om*/

    return menuBar;
}

From source file:org.omegat.gui.issues.IssuesPanelController.java

JMenuBar generateMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = menuBar.add(new JMenu(OStrings.getString("ISSUES_WINDOW_MENU_OPTIONS")));

    {//from   w w  w  . j  a  va 2  s  .  co  m
        // Tags item is hard-coded because it is not disableable and is implemented differently from all
        // others.
        JCheckBoxMenuItem tagsItem = new JCheckBoxMenuItem(OStrings.getString(
                "ISSUES_WINDOW_MENU_OPTIONS_TOGGLE_PROVIDER", OStrings.getString("ISSUES_TAGS_PROVIDER_NAME")));
        tagsItem.setSelected(true);
        tagsItem.setEnabled(false);
        menu.add(tagsItem);
    }

    Set<String> disabledProviders = IssueProviders.getDisabledProviderIds();
    IssueProviders.getIssueProviders().stream().sorted(Comparator.comparing(IIssueProvider::getId))
            .forEach(provider -> {
                String label = StringUtil.format(
                        OStrings.getString("ISSUES_WINDOW_MENU_OPTIONS_TOGGLE_PROVIDER"), provider.getName());
                JCheckBoxMenuItem item = new JCheckBoxMenuItem(label);
                item.addActionListener(e -> {
                    IssueProviders.setProviderEnabled(provider.getId(), item.isSelected());
                    refreshData(selectedEntry, selectedType);
                });
                item.setSelected(!disabledProviders.contains(provider.getId()));
                menu.add(item);
            });

    menu.addSeparator();

    {
        JCheckBoxMenuItem askItem = new JCheckBoxMenuItem(OStrings.getString("ISSUES_WINDOW_MENU_DONT_ASK"));
        askItem.setSelected(Preferences.isPreference(Preferences.ISSUE_PROVIDERS_DONT_ASK));
        askItem.addActionListener(
                e -> Preferences.setPreference(Preferences.ISSUE_PROVIDERS_DONT_ASK, askItem.isSelected()));
        menu.add(askItem);
    }
    return menuBar;
}

From source file:org.omegat.gui.scripting.ScriptingWindow.java

protected void buildSetsMenu(JMenuBar mb) {

    m_setsMenu.removeAll();/*from   w w  w  .j a v  a2s  .  c  o m*/

    Mnemonics.setLocalizedText(m_setsMenu, OStrings.getString("SCW_MENU_SETS"));

    JMenuItem item = new JMenuItem();
    Mnemonics.setLocalizedText(item, OStrings.getString("SCW_MENU_SAVE_SET"));
    item.addActionListener(new SaveSetAction());
    m_setsMenu.add(item);
    m_setsMenu.addSeparator();

    if (m_scriptsDirectory == null) {
        return;
    }

    for (File script : m_scriptsDirectory.listFiles(new FileFilter() {

        @Override
        public boolean accept(File script) {
            return script.getName().endsWith(".set");
        }

    })) {

        ScriptSet set = new ScriptSet(script);

        JMenuItem setMenuItem = new JMenuItem();
        setMenuItem.setText(set.getTitle());
        setMenuItem.putClientProperty("set", set);
        setMenuItem.addActionListener(new LoadSetAction());

        m_setsMenu.add(setMenuItem);
    }

    mb.add(m_setsMenu);
    //m_scriptList.setListData(items.toArray(new ScriptItem[items.size()]));
}