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:ee.ioc.cs.vsle.editor.Editor.java

/**
 * //from   w  w w.  j  a  v  a  2  s . c om
 */
private void makeToolsMenu(JMenuBar _menuBar) {

    JMenu menu = new JMenu(Menu.MENU_TOOLS);
    menu.setMnemonic(KeyEvent.VK_T);
    _menuBar.add(menu);

    JMenuItem menuItem = new JMenuItem(Menu.EXPERT_TABLE);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    if (RuntimeProperties.isFromWebstart()) {
        menuItem = new JMenuItem(Menu.ICON_EDITOR);
        menuItem.addActionListener(getActionListener());
        menu.add(menuItem);
    }

    menuItem = new JCheckBoxMenuItem(Menu.SHOW_ALGORITHM, RuntimeProperties.isShowAlgorithm());
    menuItem.setToolTipText("If checked, after planning a window with the synthesized algorithm will be shown");
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    menuItem = new JMenuItem(Menu.VIEW_THREADS);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    menuItem = new JMenuItem(Menu.JAVA_CONSOLE);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
}

From source file:br.ufrgs.enq.jcosmo.ui.COSMOSACDialog.java

public COSMOSACDialog() {
    super("JCOSMO Simple");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLayout(new BorderLayout());

    db = COSMOSACDataBase.getInstance();

    COSMOSAC models[] = new COSMOSAC[5];
    models[0] = new COSMOSAC();
    models[1] = new COSMOPAC();
    models[2] = new COSMOSAC_SVP();
    models[3] = new COSMOSAC_G();
    models[4] = new PCMSAC();
    modelBox = new JComboBox(models);
    modelBox.addActionListener(this);

    JPanel north = new JPanel(new GridLayout(0, 2));
    add(north, BorderLayout.NORTH);
    JPanel northAba1 = new JPanel(new GridLayout(0, 4));
    JPanel northAba2 = new JPanel(new GridLayout(0, 2));

    //Where the GUI is created:
    JMenuBar menuBar;/*from  www .  ja va2  s. c  o m*/
    JMenu file, help;
    JMenuItem menuItem;

    //Create the menu bar.
    menuBar = new JMenuBar();

    // the file menu
    file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);
    menuBar.add(file);
    menuItem = new JMenuItem("Quit", KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK));
    menuItem.setActionCommand(QUIT);
    menuItem.addActionListener(this);
    file.add(menuItem);

    // the help menu
    help = new JMenu("Help");
    file.setMnemonic(KeyEvent.VK_H);
    menuBar.add(help);
    menuItem = new JMenuItem("About", KeyEvent.VK_A);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
    menuItem.setActionCommand(ABOUT);
    menuItem.addActionListener(this);
    help.add(menuItem);

    setJMenuBar(menuBar);

    listModel = new DefaultListModel();
    list = new JList(listModel);
    list.setBorder(BorderFactory.createTitledBorder("compounds"));
    list.setVisibleRowCount(2);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane listScrollPane = new JScrollPane(list);

    JButton addButton = new JButton("Add");
    addButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new AddCompoundDialog(COSMOSACDialog.this);
        }
    });

    removeButton = new JButton("Remove");
    removeButton.addActionListener(this);
    visibRemove(false);

    JButton calcButton = new JButton("Calculate");
    calcButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            rebuildChart();
            rebuildSigmaProfiles();
        }
    });

    JButton refreshButton = new JButton("Refresh");
    refreshButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            rebuildSigmaProfiles();
        }
    });

    ignoreSGButton = new JCheckBox("Ignore SG");
    ignoreSGButton.setToolTipText("Toogles the ignore flag for the Staverman-Guggenheim term");
    ignoreSGButton.addActionListener(this);

    JPanel but = new JPanel(new GridLayout(0, 1));
    but.add(addButton, BorderLayout.EAST);
    but.add(removeButton, BorderLayout.EAST);
    but.add(modelBox);
    north.add(listScrollPane);
    north.add(but);

    northAba1.add(new JLabel("Temperature [K]"));
    northAba1.add(temperature = new JTextField(10));
    temperature.setText("298");

    northAba1.add(new JLabel("Sigma HB"));
    northAba1.add(sigmaHB = new JTextField(10));
    northAba1.add(new JLabel("Sigma HB2"));
    northAba1.add(sigmaHB2 = new JTextField(10));
    northAba1.add(new JLabel("Sigma HB3"));
    northAba1.add(sigmaHB3 = new JTextField(10));

    northAba1.add(new JLabel("Charge HB"));
    northAba1.add(chargeHB = new JTextField(10));

    northAba1.add(new JLabel("Sigma Disp"));
    northAba1.add(sigmaDisp = new JTextField(10));
    northAba1.add(new JLabel("Charge Disp"));
    northAba1.add(chargeDisp = new JTextField(10));

    northAba1.add(new JLabel("Beta"));
    northAba1.add(beta = new JTextField(10));
    northAba1.add(new JLabel("fpol"));
    northAba1.add(fpol = new JTextField(10));
    northAba1.add(new JLabel("Anorm"));
    northAba1.add(anorm = new JTextField(10));

    northAba1.add(ignoreSGButton);
    northAba1.add(calcButton);
    northAba2.add(new JLabel(""));
    northAba2.add(refreshButton);

    //      chart = new JLineChart();
    //      add(chart, BorderLayout.CENTER);
    //      chart.setTitle("Gamma Plot");
    //      chart.setSubtitle("");
    //      chart.setXAxisLabel("Mole Fraction, x_1");
    //      chart.setYAxisLabel("ln gamma, gE/RT");
    //      chart.setSource(getTitle());
    //      chart.setLegendPosition(LegendPosition.BOTTOM);
    //      chart.setShapesVisible(true);

    JFreeChart chart = ChartFactory.createXYLineChart(null, "Mole Fraction, x_1", "ln gamma, gE/RT", null,
            PlotOrientation.VERTICAL, true, true, false);
    plot = (XYPlot) chart.getPlot();
    plot.getDomainAxis().setAutoRange(false);
    plot.getDomainAxis().setRange(new Range(0.0, 1.0));

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
    r.setUseFillPaint(true);
    r.setBaseFillPaint(Color.white);
    r.setBaseShapesVisible(true);

    JFreeChart sigmaProfileChart = ChartFactory.createXYLineChart(null, "sigma", "P^x", null,
            PlotOrientation.VERTICAL, true, true, false);
    sigmaProfilePlot = sigmaProfileChart.getXYPlot();
    sigmaProfilePlot.getDomainAxis().setAutoRange(false);
    sigmaProfilePlot.getDomainAxis().setRange(new Range(-0.025, 0.025));

    //      sigmaProfilePlot.setBackgroundPaint(Color.lightGray);
    //      sigmaProfilePlot.setDomainGridlinePaint(Color.white);
    //      sigmaProfilePlot.setRangeGridlinePaint(Color.white);

    JFreeChart chartSegGamma = ChartFactory.createXYLineChart(null, "sigma", "Segment Gamma", null,
            PlotOrientation.VERTICAL, true, true, false);
    plotSegGamma = (XYPlot) chartSegGamma.getPlot();

    JPanel south = new JPanel();
    south.setLayout(new FlowLayout());
    south.add(new JLabel("<html>ln &gamma;<sup>&infin;</sup><sub>1</sub>:</html>"));
    south.add(lnGammaInf1Label = new JLabel());
    south.add(new JLabel("<html>ln &gamma;<sup>&infin;</sup><sub>2</sub>:</html>"));
    south.add(lnGammaInf2Label = new JLabel());
    south.add(Box.createHorizontalStrut(20));
    south.add(new JLabel("<html>&gamma;<sup>&infin;</sup><sub>1</sub>:</html>"));
    south.add(gammaInf1Label = new JLabel());
    south.add(new JLabel("<html>&gamma;<sup>&infin;</sup><sub>2</sub>:</html>"));
    south.add(gammaInf2Label = new JLabel());

    JPanel aba1 = new JPanel(new BorderLayout());
    aba1.add(northAba1, BorderLayout.NORTH);
    JPanel chartsPanel = new JPanel(new GridLayout(0, 2));
    aba1.add(chartsPanel, BorderLayout.CENTER);
    chartsPanel.add(new ChartPanel(chart));
    chartsPanel.add(new ChartPanel(chartSegGamma));
    aba1.add(south, BorderLayout.SOUTH);

    JPanel aba2 = new JPanel(new BorderLayout());
    aba2.add(northAba2, BorderLayout.NORTH);
    aba2.add(chartPanel = new ChartPanel(sigmaProfileChart), BorderLayout.CENTER);

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("gamma", aba1);
    tabbedPane.addTab("sigma", aba2);
    add(tabbedPane, BorderLayout.CENTER);

    //      cosmosac.setAEffPrime(6.596176570595075);
    //      cosmosac.setCoord(11.614599507917934);
    //      cosmosac.setVnorm(56.36966406129967);
    //      cosmosac.setAnorm(41.56058649432742);
    //      cosmosac.setCHB(65330.19484947528);
    //      cosmosac.setSigmaHB(0.008292411048046008);

    //Display the window.
    setSize(800, 600);
    setLocationRelativeTo(null);
    modelBox.setSelectedIndex(0);
    setVisible(true);

    // test for a mixture
    //      addList("WATER");
    //      addList("H3O+1");
    //      addList("OH-1");
    //      addList("CL-1");
    //      addList("OXYGEN");
    //      addList("sec-butylamine");
    //      addList("hydrogen-fluoride");
    //      addList("ACETONE");
    //      addList("METHANOL");
    //      addList("ACETONE.opt");
    //      addList("METHANOL.opt");
    //      addList("METHYL-ETHYL-KETONE");
    //      addList("ETHANOL");
    //      addList("N-HEPTANE");
    //      addList("PROPIONIC-ACID");
    //      addList("EMIM");
    //      addList("NTF2");
    //      addList("DCA");
    //      addList("N-OCTANE");
    addList("ETHYLENE CARBONATE");
    addList("BENZENE");
    addList("TOLUENE");
    removeButton.setEnabled(true);
}

From source file:com.isencia.passerelle.hmi.generic.GenericHMI.java

public void addPrefsMenu(final JMenuBar menuBar) {
    final JMenu prefsMenu = new JMenu(HMIMessages.getString(HMIMessages.MENU_PREFS));
    prefsMenu.setMnemonic(HMIMessages.getString(HMIMessages.MENU_PREFS + HMIMessages.KEY).charAt(0));
    final JMenuItem layoutMenuItem = new JMenuItem(HMIMessages.getString(HMIMessages.MENU_LAYOUT),
            HMIMessages.getString(HMIMessages.MENU_LAYOUT + HMIMessages.KEY).charAt(0));
    layoutMenuItem.addActionListener(new ColumnCountDialogOpener());
    prefsMenu.add(layoutMenuItem);/*from   w w  w.ja  v a2  s .  c o m*/
    final JMenuItem actorOrderMenuItem = new JMenuItem(HMIMessages.getString(HMIMessages.MENU_ACTOR_ORDER),
            HMIMessages.getString(HMIMessages.MENU_ACTOR_ORDER + HMIMessages.KEY).charAt(0));
    actorOrderMenuItem.addActionListener(new ActorOrderOpener());
    prefsMenu.add(actorOrderMenuItem);
    final JMenuItem paramFilterMenuItem = new JMenuItem(
            HMIMessages.getString(HMIMessages.MENU_PARAM_VISIBILITY),
            HMIMessages.getString(HMIMessages.MENU_PARAM_VISIBILITY + HMIMessages.KEY).charAt(0));
    paramFilterMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_MASK));
    paramFilterMenuItem.addActionListener(new ParameterFilterOpener());
    prefsMenu.add(paramFilterMenuItem);
    menuBar.add(prefsMenu);

    StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_PREFS,
            prefsMenu);
}

From source file:edu.brown.gui.CatalogViewer.java

/**
 * /*from  w  ww .  j a  v  a  2s.  c  om*/
 */
protected void viewerInit() {
    // ----------------------------------------------
    // MENU
    // ----------------------------------------------
    JMenu menu;
    JMenuItem menuItem;

    // 
    // File Menu
    //
    menu = new JMenu("File");
    menu.getPopupMenu().setLightWeightPopupEnabled(false);
    menu.setMnemonic(KeyEvent.VK_F);
    menu.getAccessibleContext().setAccessibleDescription("File Menu");
    menuBar.add(menu);

    menuItem = new JMenuItem("Open Catalog From File");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Open Catalog From File");
    menuItem.addActionListener(this.menuHandler);
    menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.CATALOG_OPEN_FILE);
    menu.add(menuItem);

    menuItem = new JMenuItem("Open Catalog From Jar");
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Open Catalog From Project Jar");
    menuItem.addActionListener(this.menuHandler);
    menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.CATALOG_OPEN_JAR);
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem("Quit", KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Quit Program");
    menuItem.addActionListener(this.menuHandler);
    menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.QUIT);
    menu.add(menuItem);

    // ----------------------------------------------
    // CATALOG TREE PANEL
    // ----------------------------------------------
    this.catalogTree = new JTree();
    this.catalogTree.setEditable(false);
    this.catalogTree.setCellRenderer(new CatalogViewer.CatalogTreeRenderer());
    this.catalogTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    this.catalogTree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) CatalogViewer.this.catalogTree
                    .getLastSelectedPathComponent();
            if (node == null)
                return;

            Object user_obj = node.getUserObject();
            String new_text = ""; // <html>";
            boolean text_mode = true;
            if (user_obj instanceof WrapperNode) {
                CatalogType catalog_obj = ((WrapperNode) user_obj).getCatalogType();
                new_text += CatalogViewer.this.getAttributesText(catalog_obj);
            } else if (user_obj instanceof AttributesNode) {
                AttributesNode wrapper = (AttributesNode) user_obj;
                new_text += wrapper.getAttributes();

            } else if (user_obj instanceof PlanTreeCatalogNode) {
                final PlanTreeCatalogNode wrapper = (PlanTreeCatalogNode) user_obj;
                text_mode = false;

                CatalogViewer.this.mainPanel.remove(0);
                CatalogViewer.this.mainPanel.add(wrapper.getPanel(), BorderLayout.CENTER);
                CatalogViewer.this.mainPanel.validate();
                CatalogViewer.this.mainPanel.repaint();

                if (SwingUtilities.isEventDispatchThread() == false) {
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            wrapper.centerOnRoot();
                        }
                    });
                } else {
                    wrapper.centerOnRoot();
                }

            } else {
                new_text += CatalogViewer.this.getSummaryText();
            }

            // Text Mode
            if (text_mode) {
                if (CatalogViewer.this.text_mode == false) {
                    CatalogViewer.this.mainPanel.remove(0);
                    CatalogViewer.this.mainPanel.add(CatalogViewer.this.textInfoPanel);
                }
                CatalogViewer.this.textInfoTextArea.setText(new_text);

                // Scroll to top
                CatalogViewer.this.textInfoTextArea.grabFocus();
            }

            CatalogViewer.this.text_mode = text_mode;
        }
    });
    this.generateCatalogTree(this.catalog, this.catalog_file_path.getName());

    //
    // Text Information Panel
    //
    this.textInfoPanel = new JPanel();
    this.textInfoPanel.setLayout(new BorderLayout());
    this.textInfoTextArea = new JTextArea();
    this.textInfoTextArea.setEditable(false);
    this.textInfoTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
    this.textInfoTextArea.setText(this.getSummaryText());
    this.textInfoTextArea.addFocusListener(new FocusListener() {
        @Override
        public void focusLost(FocusEvent e) {
            // TODO Auto-generated method stub
        }

        @Override
        public void focusGained(FocusEvent e) {
            CatalogViewer.this.scrollTextInfoToTop();
        }
    });
    this.textInfoScroller = new JScrollPane(this.textInfoTextArea);
    this.textInfoPanel.add(this.textInfoScroller, BorderLayout.CENTER);
    this.mainPanel = new JPanel(new BorderLayout());
    this.mainPanel.add(textInfoPanel, BorderLayout.CENTER);

    //
    // Search Toolbar
    //
    JPanel searchPanel = new JPanel();
    searchPanel.setLayout(new BorderLayout());
    JPanel innerSearchPanel = new JPanel();
    innerSearchPanel.setLayout(new BoxLayout(innerSearchPanel, BoxLayout.X_AXIS));
    innerSearchPanel.add(new JLabel("Search: "));
    this.searchField = new JTextField(30);
    innerSearchPanel.add(this.searchField);
    searchPanel.add(innerSearchPanel, BorderLayout.EAST);

    this.searchField.addKeyListener(new KeyListener() {
        private String last = null;

        @Override
        public void keyReleased(KeyEvent e) {
            String value = CatalogViewer.this.searchField.getText().toLowerCase().trim();
            if (!value.isEmpty() && (this.last == null || !this.last.equals(value))) {
                CatalogViewer.this.search(value);
            }
            this.last = value;
        }

        @Override
        public void keyTyped(KeyEvent e) {
            // Do nothing...
        }

        @Override
        public void keyPressed(KeyEvent e) {
            // Do nothing...
        }
    });

    // Putting it all together
    JScrollPane scrollPane = new JScrollPane(this.catalogTree);
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    topPanel.add(searchPanel, BorderLayout.NORTH);
    topPanel.add(scrollPane, BorderLayout.CENTER);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, topPanel, this.mainPanel);
    splitPane.setDividerLocation(400);

    this.add(splitPane, BorderLayout.CENTER);
}

From source file:org.jfree.chart.demo.SuperDemo.java

private JMenuBar createMenuBar() {
    JMenuBar jmenubar = new JMenuBar();
    JMenu jmenu = new JMenu("File", true);
    jmenu.setMnemonic('F');
    JMenuItem jmenuitem = new JMenuItem("Export to PDF...", 112);
    jmenuitem.setActionCommand("EXPORT_TO_PDF");
    jmenuitem.addActionListener(this);
    jmenu.add(jmenuitem);/*w w w .j  av  a  2s.c o  m*/
    jmenu.addSeparator();
    JMenuItem jmenuitem1 = new JMenuItem("Exit", 120);
    jmenuitem1.setActionCommand("EXIT");
    jmenuitem1.addActionListener(this);
    jmenu.add(jmenuitem1);
    jmenubar.add(jmenu);
    return jmenubar;
}

From source file:burlov.ultracipher.swing.SwingGuiApplication.java

private JMenuBar createMenuBar() {
    JMenuBar bar = new JMenuBar();
    JMenu menu = null;
    /*/*from w w  w.j  a v a 2 s.  c  om*/
     * 'File' Menue
     */
    menu = new JMenu("File");
    menu.setMnemonic(KeyEvent.VK_F);
    bar.add(menu);

    JMenuItem item = new JMenuItem("Save database");
    item.setAccelerator(KeyStroke.getKeyStroke("control S"));
    item.setMnemonic(KeyEvent.VK_S);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            saveDatabase();
        }
    });
    menu.add(item);

    item = new JMenuItem("Download database");
    item.setMnemonic(KeyEvent.VK_L);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            downloadAndMergeData();
        }
    });
    menu.add(item);

    item = new JMenuItem("Edit sync account");
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            editSyncAccount();
        }
    });
    menu.add(item);
    menu.add(new JSeparator());

    JMenu submenu = new JMenu("Import");
    menu.add(submenu);

    item = new JMenuItem("From CSV");
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            importCSV();
        }
    });
    submenu.add(item);

    submenu = new JMenu("Export");
    menu.add(submenu);

    item = new JMenuItem("As CSV");
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            exportCSV();
        }
    });
    submenu.add(item);
    item = new JMenuItem("Change passphrase");
    menu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            changePassword();
        }
    });

    /*
     * 'Edit' Menue
     */
    menu = new JMenu("Edit");
    menu.setMnemonic(KeyEvent.VK_E);
    bar.add(menu);
    item = menu.add(mainPanel.getNewEntryAction());
    item.setMnemonic(KeyEvent.VK_N);
    item = menu.add(mainPanel.getDeleteEntryAction());
    item.setMnemonic(KeyEvent.VK_D);

    menu.add(new JSeparator());

    menu = new JMenu("Tools");
    // item = new JMenuItem("Passwort generator");
    // menu.add(item);
    // item.addActionListener(new ActionListener() {
    //
    // @Override
    // public void actionPerformed(ActionEvent e) {
    // passGenerator.setVisible(false);
    // passGenerator.setLocationRelativeTo(getMainFrame());
    // passGenerator.setVisible(true);
    // }
    // });
    item = new JMenuItem("Screen keyboard");
    menu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            screenKeyboard.setLocationRelativeTo(getMainFrame());
            screenKeyboard.setVisible(true);

        }
    });
    item = new JMenuItem("File digester");
    menu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            digester.setLocationRelativeTo(getMainFrame());
            digester.setVisible(true);

        }
    });
    bar.add(menu);
    /*
     * 'Help' Menue
     */
    menu = new JMenu("Help");
    menu.setMnemonic(KeyEvent.VK_H);
    bar.add(menu);

    item = new JMenuItem("Performance test");
    menu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            measurePerformance();
        }
    });
    item = new JMenuItem("System info");
    menu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            showSystemInfo();
        }
    });
    item = new JMenuItem("About");
    menu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            String text = "<html>Ultracipher 6.1<br>(C) Copyright 2015 Paul Burlov<br><br>"
                    + "Encryption strength: 768Bit (6 x 128Bit keys)<br>Cipher cascade: AES/Twofish/Serpent/CAST6/SEED/Camellia"
                    + "<br>Encryption mode: Two pass CBC"
                    + "<br>Key derivation algorithm: SCrypt with N=2^14,P=8,R=1<br><br> "
                    + "This product includes software developed by the<br>"
                    + "<ul><li>Apache Software Foundation "
                    + "<a href='http://www.apache.org'>http://www.apache.org</a>"
                    + "<li>Legion of the Bouncy Castle <a href='http://bouncycastle.org/'>http://bouncycastle.org</a>"
                    + "<li>Project SwingX" + "<li>Bytecode Pty Ltd." + "</ul></html>";
            JOptionPane.showMessageDialog(getMainFrame(), text, "", JOptionPane.INFORMATION_MESSAGE,
                    getAppIcon());
        }
    });
    bar.add(Box.createHorizontalGlue());
    menu = new JMenu("Keyboard");
    ButtonGroup group = new ButtonGroup();
    JRadioButtonMenuItem radioitem = new JRadioButtonMenuItem("System");
    radioitem.setSelected(true);
    group.add(radioitem);
    radioitem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            translator.resetMapping();
        }
    });
    menu.add(radioitem);
    radioitem = new JRadioButtonMenuItem("Futhark runes");
    group.add(radioitem);
    radioitem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            translator.initForFuthark();
        }
    });
    menu.add(radioitem);
    radioitem = new JRadioButtonMenuItem("Anglo-Saxon runes");
    group.add(radioitem);
    radioitem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            translator.initForAngloSaxon();
        }
    });
    menu.add(radioitem);
    bar.add(menu);
    // bar.add(Box.createHorizontalGlue());
    // bar.add(new PassGeneratorPanel());
    return bar;
}

From source file:com.opendoorlogistics.studio.appframe.AppFrame.java

private void initMenus(ActionFactory actionBuilder, MenuFactory menuBuilder, List<? extends Action> fileActions,
        List<? extends Action> editActions) {
    final JMenuBar menuBar = new JMenuBar();
    class AddSpace {
        void add() {
            JMenu dummy = new JMenu();
            dummy.setEnabled(false);//from w w  w. j  a  va2 s.c o m
            menuBar.add(dummy);
        }
    }
    AddSpace addSpace = new AddSpace();

    // add file menu ... build on the fly for recent files..
    setJMenuBar(menuBar);
    final JMenu mnFile = new JMenu("File");
    mnFile.setMnemonic('F');
    mnFile.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(MenuEvent e) {
            initFileMenu(mnFile, fileActions, actionBuilder, menuBuilder);
        }

        @Override
        public void menuDeselected(MenuEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void menuCanceled(MenuEvent e) {
            // TODO Auto-generated method stub

        }
    });
    initFileMenu(mnFile, fileActions, actionBuilder, menuBuilder);
    menuBar.add(mnFile);
    addSpace.add();

    // add edit menu
    JMenu mnEdit = new JMenu("Edit");
    mnEdit.setMnemonic('E');
    menuBar.add(mnEdit);
    addSpace.add();
    for (Action action : editActions) {
        mnEdit.add(action);
        //         if (action.accelerator != null) {
        //            item.setAccelerator(action.accelerator);
        //         }
    }

    // add run scripts menu (hidden until a datastore is loaded)
    mnScripts = new JMenu(appPermissions.isScriptEditingAllowed() ? "Run script" : "Run");
    mnScripts.setMnemonic('R');
    mnScripts.setVisible(false);
    mnScripts.addMenuListener(new MenuListener() {

        private void addScriptNode(JMenu parentMenu, boolean usePopupForChildren, ScriptNode node) {
            if (node.isAvailable() == false) {
                return;
            }
            if (node.isRunnable()) {
                parentMenu.add(new AbstractAction(node.getDisplayName(), node.getIcon()) {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        postScriptExecution(node.getFile(), node.getLaunchExecutorId());
                    }
                });
            } else if (node.getChildCount() > 0) {
                JMenu newParent = parentMenu;
                if (usePopupForChildren) {
                    newParent = new JMenu(node.getDisplayName());
                    parentMenu.add(newParent);
                }
                ;
                for (int i = 0; i < node.getChildCount(); i++) {
                    addScriptNode(newParent, true, (ScriptNode) node.getChildAt(i));
                }
            }
        }

        @Override
        public void menuSelected(MenuEvent e) {
            mnScripts.removeAll();
            ScriptNode[] scripts = scriptsPanel.getScripts();
            for (final ScriptNode item : scripts) {
                addScriptNode(mnScripts, scripts.length > 1, item);
            }
            mnScripts.validate();
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });
    menuBar.add(mnScripts);
    addSpace.add();

    // add create script menu
    if (appPermissions.isScriptEditingAllowed()) {
        JMenu scriptsMenu = menuBuilder.createScriptCreationMenu(this, scriptManager);
        if (scriptsMenu != null) {
            menuBar.add(scriptsMenu);
        }
        addSpace.add();
    }

    // tools menu
    JMenu tools = new JMenu("Tools");
    menuBar.add(tools);
    JMenu memoryCache = new JMenu("Memory cache");
    tools.add(memoryCache);
    memoryCache.add(new AbstractAction("View cache statistics") {

        @Override
        public void actionPerformed(ActionEvent e) {
            TextInformationDialog dlg = new TextInformationDialog(AppFrame.this, "Memory cache statistics",
                    ApplicationCache.singleton().getUsageReport());
            dlg.setMinimumSize(new Dimension(400, 400));
            dlg.setLocationRelativeTo(AppFrame.this);
            dlg.setVisible(true);
        }
    });
    memoryCache.add(new AbstractAction("Clear memory cache") {

        @Override
        public void actionPerformed(ActionEvent e) {
            ApplicationCache.singleton().clearCache();
        }
    });
    addSpace.add();

    // add window menu
    JMenu mnWindow = menuBuilder.createWindowsMenu(this);
    mnWindow.add(new AbstractAction("Show all tables") {

        @Override
        public void actionPerformed(ActionEvent e) {
            tileTables();
        }
    });

    JMenu mnResizeTo = new JMenu("Resize application to...");
    for (final int[] size : new int[][] { new int[] { 1280, 720 }, new int[] { 1920, 1080 } }) {
        mnResizeTo.add(new AbstractAction("" + size[0] + " x " + size[1]) {

            @Override
            public void actionPerformed(ActionEvent e) {
                // set standard layout
                setSize(size[0], size[1]);
                splitterMain.setDividerLocation(0.175);
                splitterLeftSide.setDividerLocation(0.3);
            }
        });
    }
    mnWindow.add(mnResizeTo);
    menuBar.add(mnWindow);
    addSpace.add();

    menuBar.add(menuBuilder.createHelpMenu(actionBuilder, this));

    addSpace.add();

}

From source file:ch.fork.AdHocRailway.ui.AdHocRailway.java

private void initMenu() {
    menuBar = new JMenuBar();
    /* FILE *///from w ww .java 2  s . co  m
    final JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);

    final JMenuItem newItem = new JMenuItem(new NewFileAction());
    newItem.setMnemonic(KeyEvent.VK_N);
    newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));

    final JMenuItem openItem = new JMenuItem(new OpenFileAction());
    openItem.setMnemonic(KeyEvent.VK_O);
    openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));

    final JMenuItem openDatabaseItem = new JMenuItem(new OpenDatabaseAction());

    saveItem = new JMenuItem(new SaveAction());
    saveItem.setMnemonic(KeyEvent.VK_S);
    saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));

    saveAsItem = new JMenuItem(new SaveAsAction());
    saveAsItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));

    final JMenuItem importAllItem = new JMenuItem(new ImportAllAction());
    final JMenuItem importLocomotivesItem = new JMenuItem(new ImportLocomotivesAction());
    final JMenuItem exportLocomotivesItem = new JMenuItem(new ExportLocomotivesAction());
    final JMenuItem exportAllItem = new JMenuItem(new ExportAllAction());

    final JMenu importMenu = new JMenu("Import");
    importMenu.add(importAllItem);
    importMenu.add(importLocomotivesItem);
    final JMenu exportMenu = new JMenu("Export");
    exportMenu.add(exportLocomotivesItem);
    exportMenu.add(exportAllItem);

    final JMenuItem clearLocomotivesItem = new JMenuItem(new ClearLocomotivesAction());
    final JMenuItem clearTurnoutsRoutesItem = new JMenuItem(new ClearTurnoutsAndRoutesAction());

    final JMenu clearMenu = new JMenu("Clear");
    clearMenu.add(clearLocomotivesItem);
    clearMenu.add(clearTurnoutsRoutesItem);

    final JMenuItem exitItem = new JMenuItem(new ExitAction());
    exitItem.setMnemonic(KeyEvent.VK_X);
    exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));

    fileMenu.add(newItem);
    fileMenu.add(openItem);
    fileMenu.add(openDatabaseItem);
    fileMenu.add(saveItem);
    fileMenu.add(saveAsItem);
    fileMenu.add(new JSeparator());
    fileMenu.add(importMenu);
    fileMenu.add(exportMenu);
    fileMenu.add(clearMenu);
    fileMenu.add(new JSeparator());
    fileMenu.add(exitItem);

    /* EDIT */
    final JMenu editMenu = new JMenu("Edit");
    enableEditing = new JCheckBoxMenuItem(new EnableEditingAction());

    switchesItem = new JMenuItem(new TurnoutAction());
    routesItem = new JMenuItem(new RoutesAction());
    locomotivesItem = new JMenuItem(new LocomotivesAction());
    preferencesItem = new JMenuItem(new PreferencesAction());
    enableEditing.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.ALT_MASK));

    switchesItem.setMnemonic(KeyEvent.VK_T);
    switchesItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.ALT_MASK));
    routesItem.setMnemonic(KeyEvent.VK_R);
    routesItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.ALT_MASK));
    locomotivesItem.setMnemonic(KeyEvent.VK_L);
    locomotivesItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.ALT_MASK));
    preferencesItem.setMnemonic(KeyEvent.VK_P);
    preferencesItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK));
    editMenu.add(enableEditing);
    editMenu.add(new JSeparator());
    editMenu.add(switchesItem);
    editMenu.add(routesItem);
    editMenu.add(locomotivesItem);
    editMenu.add(new JSeparator());
    editMenu.add(preferencesItem);

    /* DAEMON */
    final JMenu daemonMenu = new JMenu("Device");
    daemonConnectItem = new JMenuItem(new ConnectAction());
    daemonConnectItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
    daemonDisconnectItem = new JMenuItem(new DisconnectAction());
    daemonPowerOnItem = new JMenuItem(new PowerOnAction());
    assignAccelerator(daemonPowerOnItem, "PowerOn");
    daemonPowerOnItem.setEnabled(true);
    daemonPowerOffItem = new JMenuItem(new PowerOffAction());
    assignAccelerator(daemonPowerOffItem, "PowerOff");
    daemonPowerOffItem.setEnabled(true);
    daemonDisconnectItem.setEnabled(false);
    daemonMenu.add(daemonConnectItem);
    daemonMenu.add(daemonDisconnectItem);
    daemonMenu.add(new JSeparator());
    daemonMenu.add(daemonPowerOnItem);
    daemonMenu.add(daemonPowerOffItem);

    /* VIEW */
    final JMenu viewMenu = new JMenu("View");
    final JMenuItem refreshItem = new JMenuItem(new RefreshAction());
    final JMenuItem fullscreenItem = new JMenuItem(new ToggleFullscreenAction());

    viewMenu.add(refreshItem);
    viewMenu.add(fullscreenItem);

    /* HELP */
    // JMenu helpMenu = new JMenu("Help");
    addMenu(fileMenu);
    addMenu(editMenu);
    addMenu(daemonMenu);
    addMenu(viewMenu);
    // addMenu(helpMenu);
    setJMenuBar(menuBar);
}

From source file:ResourceBundleSupport.java

/**
 * Returns a JMenu created from a resource bundle definition.
 * <p/>/*from w w  w  . j av  a  2 s .c  o m*/
 * The menu definition consists of two keys, the name of the menu and the
 * mnemonic for that menu. Both keys share a common prefix, which is
 * extended by ".name" for the name of the menu and ".mnemonic" for the
 * mnemonic.
 * <p/>
 * <pre>
 * # define the file menu
 * menu.file.name=File
 * menu.file.mnemonic=F
 * </pre>
 * The menu definition above can be used to create the menu by calling
 * <code>createMenu ("menu.file")</code>.
 *
 * @param keyPrefix the common prefix for that menu
 * @return the created menu
 */
public JMenu createMenu(final String keyPrefix) {
    final JMenu retval = new JMenu();
    retval.setText(getString(keyPrefix + ".name"));
    retval.setMnemonic(getMnemonic(keyPrefix + ".mnemonic").intValue());
    return retval;
}

From source file:fll.scheduler.SchedulerUI.java

private JMenu createFileMenu() {
    final JMenu menu = new JMenu("File");
    menu.setMnemonic('f');

    menu.add(mPreferencesAction);// ww  w.  ja  v  a 2  s .  c  o m
    menu.add(mExitAction);

    return menu;
}