Example usage for javax.swing JMenu JMenu

List of usage examples for javax.swing JMenu JMenu

Introduction

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

Prototype

public JMenu(Action a) 

Source Link

Document

Constructs a menu whose properties are taken from the Action supplied.

Usage

From source file:net.chaosserver.timelord.swingui.TimelordMenu.java

/**
 * Creates a new instance of the help menu.
 *
 * @return the new help menu//from   www.j  ava2  s . com
 */
protected JMenu createHelpMenu() {
    JMenuItem menuItem;
    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic(KeyEvent.VK_H);
    this.add(helpMenu);

    menuItem = new JMenuItem("Help Topics", KeyEvent.VK_H);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_H, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));

    try {
        URL hsURL = HelpSet.findHelpSet(this.getClass().getClassLoader(),
                "net/chaosserver/timelord/help/TimelordHelp.hs");
        HelpSet hs = new HelpSet(null, hsURL);
        HelpBroker hb = hs.createHelpBroker();
        menuItem.addActionListener(new CSH.DisplayHelpFromSource(hb));
    } catch (HelpSetException e) {
        menuItem.setEnabled(false);
    }

    // menuItem.setActionCommand(ACTION_ABOUT);
    helpMenu.add(menuItem);

    menuItem = new JMenuItem("Log Window");
    menuItem.setActionCommand(ACTION_LOG);
    menuItem.addActionListener(this);
    menuItem.setEnabled(false);
    helpMenu.add(menuItem);

    menuItem = new JMenuItem("Cause Memory Leak");
    menuItem.setActionCommand(ACTION_LEAK);
    menuItem.addActionListener(this);
    menuItem.setEnabled(false);
    helpMenu.add(menuItem);

    if (!OsUtil.isMac()) {
        helpMenu.addSeparator();

        menuItem = new JMenuItem("About Timelord", KeyEvent.VK_A);
        menuItem.setActionCommand(ACTION_ABOUT);
        menuItem.addActionListener(this);
        helpMenu.add(menuItem);
    }

    return helpMenu;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_2.CFAstSwing.CFAstSwingSysClusterFinderJInternalFrame.java

public JMenuBar getFinderMenuBar() {
    if (finderMenuBar == null) {
        JMenuItem menuItem;//from   www.  j  a  va2s .  co  m
        finderMenuBar = new JMenuBar();
        menuFile = new JMenu("File");
        actionAddSysCluster = new ActionAddSysCluster();
        menuItem = new JMenuItem(actionAddSysCluster);
        menuFile.add(menuItem);
        actionViewSelected = new ActionViewSelectedSysCluster();
        menuItem = new JMenuItem(actionViewSelected);
        menuFile.add(menuItem);
        actionEditSelected = new ActionEditSelectedSysCluster();
        menuItem = new JMenuItem(actionEditSelected);
        menuFile.add(menuItem);
        actionDeleteSelected = new ActionDeleteSelectedSysCluster();
        menuItem = new JMenuItem(actionDeleteSelected);
        menuFile.add(menuItem);
        actionClose = new ActionClose();
        menuItem = new JMenuItem(actionClose);
        menuFile.add(menuItem);
        finderMenuBar.add(menuFile);
    }
    return (finderMenuBar);
}

From source file:com.qspin.qtaste.ui.MainPanel.java

protected void genMenu(final TestCaseTree tct) {
    final JFrame owner = this;
    JMenuBar menuBar = new JMenuBar();
    JMenu tools = new JMenu("Tools");
    tools.setMnemonic(KeyEvent.VK_T);

    // Tools|Config menu item
    JMenuItem config = new JMenuItem("Config", KeyEvent.VK_D);
    config.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            //ATEConfigEditPanel configPanel = new  ATEConfigEditPanel(null);
            //configPanel.setVisible(true);
            MainConfigFrame configFrame = new MainConfigFrame();
            configFrame.launch();//from  ww  w  . ja v  a2 s  .c  om
            configFrame.addWindowListener(new WindowListener() {

                public void windowOpened(WindowEvent e) {
                }

                public void windowClosing(WindowEvent e) {
                }

                public void windowClosed(WindowEvent e) {
                    // refresh the Configuration information display
                    refreshParams();
                }

                public void windowIconified(WindowEvent e) {
                }

                public void windowDeiconified(WindowEvent e) {
                }

                public void windowActivated(WindowEvent e) {
                }

                public void windowDeactivated(WindowEvent e) {
                }
            });

        }
    });
    tools.add(config);

    // Tools|delete results menu item
    JMenuItem deleteResults = new JMenuItem("Delete Results", KeyEvent.VK_D);
    final MainPanel ui = this;
    deleteResults.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            String baseDir = TestEngineConfiguration.getInstance().getString("reporting.generated_report_path");
            new File(baseDir, baseDir);
            // TO DO : delete really the files
            JOptionPane.showMessageDialog(ui, "Results have been deleted");

        }
    });
    tools.add(deleteResults);

    JMenu fileMenu = new JMenu("File");
    JMenuItem importTestSuites = new JMenuItem("Import TestSuites");
    importTestSuites.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            //
            mTestCasePanel.importTestSuites();

        }
    });
    fileMenu.add(importTestSuites);

    JMenu help = new JMenu("Help");
    help.setMnemonic(KeyEvent.VK_H);
    JMenuItem about = new JMenuItem("About", KeyEvent.VK_A);
    about.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            new AboutDialog(owner);
        }
    });
    help.add(about);

    JMenuItem ateUserManuel = new JMenuItem("User Manual");
    ateUserManuel.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            viewQTasteUserManuel();
        }
    });
    help.add(ateUserManuel);

    //menuBar.add(tools); // not to be used at this time!!!!!!!!!
    //menuBar.add(fileMenu);
    menuBar.add(help);
    setJMenuBar(menuBar);
}