Example usage for javax.swing JMenu setMnemonic

List of usage examples for javax.swing JMenu setMnemonic

Introduction

In this page you can find the example usage for javax.swing JMenu setMnemonic.

Prototype

@BeanProperty(visualUpdate = true, description = "the keyboard character mnemonic")
public void setMnemonic(int mnemonic) 

Source Link

Document

Sets the keyboard mnemonic on the current model.

Usage

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

public MainFrame(String version) {

    super("Galleon " + version);

    setDefaultCloseOperation(0);//  w ww .  j a  va  2 s . 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 ww  .  j a  va  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.openmicroscopy.shoola.agents.fsimporter.view.ImporterUI.java

/**
 * Helper method to create the <code>File</code> menu.
 * /*from   ww  w  .j a  va 2s  . co  m*/
 * @return See above.
 */
private JMenu createFileMenu() {
    JMenu menu = new JMenu("File");
    menu.setMnemonic(KeyEvent.VK_F);
    menu.add(new JMenuItem(controller.getAction(ImporterControl.LOG_OFF)));
    menu.add(new JMenuItem(controller.getAction(ImporterControl.EXIT)));
    return menu;
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Helper method to create the view menu.
 * /*from  w  w  w .jav  a 2  s  .c o  m*/
 * @param pref The user preferences.
 * @return The controls sub-menu.
 */
private JMenu createViewMenu(ViewerPreferences pref) {
    JMenu menu = new JMenu("Display");
    menu.setMnemonic(KeyEvent.VK_V);
    unitBarItem = new JCheckBoxMenuItem();
    unitBarItem.setSelected(model.isUnitBar());
    unitBarItem.setAction(controller.getAction(ImViewerControl.UNIT_BAR));
    menu.add(unitBarItem);
    menu.add(createScaleBarLengthSubMenu(pref));
    menu.add(createScaleBarColorSubMenu(pref));
    menu.add(new JSeparator(JSeparator.HORIZONTAL));
    menu.add(createBackgroundColorSubMenu(pref));
    //menu.add(new JSeparator(JSeparator.HORIZONTAL));
    return menu;
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Helper method to create the controls menu.
 * //w  w w  .j  ava 2  s  . c om
 * @param pref The user preferences.
 * @return The controls sub-menu.
 */
private JMenu createControlsMenu(ViewerPreferences pref) {
    JMenu menu = new JMenu("Controls");
    menu.setMnemonic(KeyEvent.VK_C);
    ViewerAction action = controller.getAction(ImViewerControl.RENDERER);

    rndItem = new JCheckBoxMenuItem();
    rndItem.setSelected(isRendererShown());
    rndItem.setAction(action);
    rndItem.setText(action.getName());
    if (pref != null)
        rndItem.setSelected(pref.isRenderer());
    //menu.add(rndItem);

    action = controller.getAction(ImViewerControl.METADATA);
    metadataItem = new JCheckBoxMenuItem();
    metadataItem.setSelected(isRendererShown());
    metadataItem.setAction(action);
    metadataItem.setText(action.getName());
    if (pref != null)
        metadataItem.setSelected(pref.isRenderer());
    //menu.add(metadataItem);

    action = controller.getAction(ImViewerControl.HISTORY);
    historyItem = new JCheckBoxMenuItem();
    historyItem.setSelected(isHistoryShown());
    historyItem.setAction(action);
    historyItem.setText(action.getName());
    if (pref != null)
        historyItem.setSelected(pref.isHistory());
    //menu.add(historyItem);

    action = controller.getAction(ImViewerControl.MOVIE);
    JMenuItem item = new JMenuItem(action);
    item.setText(action.getName());
    menu.add(item);
    action = controller.getAction(ImViewerControl.LENS);
    item = new JMenuItem(action);
    item.setText(action.getName());
    menu.add(item);
    action = controller.getAction(ImViewerControl.MEASUREMENT_TOOL);
    item = new JMenuItem(action);
    item.setText(action.getName());
    menu.add(item);
    menu.add(new JSeparator(JSeparator.HORIZONTAL));
    //Color model
    colorModelGroup = new ButtonGroup();
    action = controller.getAction(ImViewerControl.GREY_SCALE_MODEL);
    item = new JCheckBoxMenuItem();
    String cm = model.getColorModel();
    item.setSelected(cm.equals(ImViewer.GREY_SCALE_MODEL));
    item.setAction(action);
    colorModelGroup.add(item);
    menu.add(item);
    action = controller.getAction(ImViewerControl.RGB_MODEL);
    item = new JCheckBoxMenuItem();
    item.setAction(action);
    item.setSelected(cm.equals(ImViewer.RGB_MODEL));
    colorModelGroup.add(item);
    menu.add(item);

    menu.add(new JSeparator());
    action = controller.getAction(ImViewerControl.CHANNELS_ON);
    item = new JMenuItem(action);
    item.setText(action.getName());
    menu.add(item);
    action = controller.getAction(ImViewerControl.CHANNELS_OFF);
    item = new JMenuItem(action);
    item.setText(action.getName());
    menu.add(item);

    menu.add(new JSeparator());
    action = controller.getAction(ImViewerControl.SAVE);
    item = new JMenuItem(action);
    item.setText(action.getName());
    menu.add(item);
    action = controller.getAction(ImViewerControl.PREFERENCES);
    item = new JMenuItem(action);
    item.setText(action.getName());
    //menu.add(item);
    return menu;
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Helper method to create the show View menu. 
 * //  www  . j  a  v a2 s  . c  o  m
 * @return See above.
 */
private JMenu createShowViewMenu() {
    JMenu menu = new JMenu("View");
    menu.setMnemonic(KeyEvent.VK_S);
    JMenuItem item = new JMenuItem(controller.getAction(ImViewerControl.TAB_GRID));
    if (model.isBigImage() || (model.isLifetimeImage() && model.getModuloT() == null))
        item.setEnabled(false);
    else
        item.setEnabled(model.getMaxC() > 1);
    menu.add(item);
    item = new JMenuItem(controller.getAction(ImViewerControl.TAB_PROJECTION));
    item.setEnabled(model.getMaxZ() > 1 && !model.isBigImage());
    menu.add(item);
    return menu;
}

From source file:org.openmicroscopy.shoola.env.ui.TaskBarView.java

/**
 * Helper method to create the file menu.
 *
 * @return The file menu.// ww w.j  a v  a 2  s .c  o  m
 */
private JMenu createFileMenu() {
    JMenu file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);
    return file;
}

From source file:org.openmicroscopy.shoola.env.ui.TaskBarView.java

/**
 * Helper method to create the window menu.
 *
 * @return The window menu./*  w  ww .j ava 2s . co m*/
 */
private JMenu createWindowMenu() {
    JMenu window = new JMenu("Window");
    window.setMnemonic(KeyEvent.VK_W);
    window.add(buttons[ACTIVITY_MI]);
    return window;
}

From source file:org.openmicroscopy.shoola.env.ui.TaskBarView.java

/**
 * Helper method to create the help menu.
 *
 * @return The help menu./*from   w w  w .j a v a  2  s. co m*/
 */
private JMenu createHelpMenu() {
    JMenu help = new JMenu("Help");
    help.setMnemonic(KeyEvent.VK_H);
    help.add(buttons[HELP_MI]);
    help.add(buttons[FORUM_MI]);
    help.add(buttons[COMMENT_MI]);
    help.add(new JSeparator(JSeparator.HORIZONTAL));
    help.add(buttons[LOG_FILE_MI]);
    help.add(buttons[UPDATES_MI]);
    return help;
}

From source file:org.pentaho.reporting.engine.classic.demo.ancient.demo.layouts.internalframe.InternalFrameDemoFrame.java

protected JMenuBar createMenuBar() {
    final JMenuBar menuBar = new JMenuBar();

    //Set up the lone menu.
    final JMenu menu = new JMenu("Document");
    menu.setMnemonic(KeyEvent.VK_D);
    menuBar.add(menu);/* w ww . java 2  s.com*/

    menu.add(new JMenuItem(new NewFrameAction()));
    menu.add(new JMenuItem(getPreviewAction()));
    menu.addSeparator();
    menu.add(new JMenuItem(getCloseAction()));

    final JMenu helpmenu = new JMenu("Help");
    helpmenu.setMnemonic(KeyEvent.VK_H);
    helpmenu.add(new JMenuItem(getAboutAction()));
    return menuBar;
}