Example usage for javax.swing JMenu addSeparator

List of usage examples for javax.swing JMenu addSeparator

Introduction

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

Prototype

public void addSeparator() 

Source Link

Document

Appends a new separator to the end of the menu.

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. jav a 2s.  c  o m
 */
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:de.tbuchloh.kiskis.gui.MainFramePanel.java

private JMenu createFileMenu() {
    final JMenu fileMenu = new JMenu(M.getString("file_menu")); //$NON-NLS-1$
    fileMenu.setMnemonic(M.getChar("file_menu_mne")); //$NON-NLS-1$
    final Action[] first = { _newFileAction, _openFileAction, _saveAction, _saveAsAction, _closeDocAction, null,
            _changeMasterPwdAction, _importAction };
    addActions(fileMenu, first);/* w  w w  .  j  ava  2 s.co  m*/
    fileMenu.add(_exportHandler.getMenu());
    final Action[] second = { null, _lockScreenAction, null, _quitAction };
    addActions(fileMenu, second);
    fileMenu.addSeparator();
    _lruFileMenu.addToMenu(fileMenu);

    _changeMasterPwdAction.setEnabled(Settings.isBufferingPwd());

    return fileMenu;
}

From source file:net.panthema.BispanningGame.GamePanel.java

public void addPopupActions(JPopupMenu popup) {

    popup.add(new AbstractAction("Center Graph") {
        private static final long serialVersionUID = 571719411574657791L;

        public void actionPerformed(ActionEvent e) {
            centerAndScaleGraph();/* w ww .  ja  va  2  s.  c  o  m*/
        }
    });

    popup.add(new AbstractAction("Relayout Graph") {
        private static final long serialVersionUID = 571719411573657791L;

        public void actionPerformed(ActionEvent e) {
            relayoutGraph();
        }
    });

    popup.add(new AbstractAction("Reset Board Colors") {
        private static final long serialVersionUID = 571719411573657796L;

        public void actionPerformed(ActionEvent e) {
            mGraph.updateOriginalColor();
            mTurnNum = 0;
            putLog("Resetting game graph's colors.");
            updateGraphMessage();
            mVV.repaint();
        }
    });

    popup.add(new AbstractAction(
            allowFreeExchange ? "Restrict to Unique Exchanges" : "Allow Free Edge Exchanges") {
        private static final long serialVersionUID = 571719411573657798L;

        public void actionPerformed(ActionEvent e) {
            allowFreeExchange = !allowFreeExchange;
            mVV.repaint();
        }
    });

    popup.add(new AbstractAction((mAutoPlayBob ? "Disable" : "Enable") + " Autoplay of Bob's Moves") {
        private static final long serialVersionUID = 571719413573657798L;

        public void actionPerformed(ActionEvent e) {
            mAutoPlayBob = !mAutoPlayBob;
        }
    });

    popup.addSeparator();

    JMenu newGraph = new JMenu("New Random Graph");
    for (int i = 0; i < actionRandomGraph.length; ++i) {
        if (actionRandomGraph[i] != null)
            newGraph.add(actionRandomGraph[i]);
    }
    newGraph.addSeparator();
    newGraph.add(getActionNewGraphType());
    popup.add(newGraph);

    JMenu newNamedGraph = new JMenu("New Named Graph");
    for (int i = 0; i < actionNamedGraph.size(); ++i) {
        if (actionNamedGraph.get(i) != null)
            newNamedGraph.add(actionNamedGraph.get(i));
    }
    popup.add(newNamedGraph);

    popup.add(new AbstractAction("Show GraphString") {
        private static final long serialVersionUID = 545719411573657792L;

        public void actionPerformed(ActionEvent e) {
            JEditorPane text = new JEditorPane("text/plain",
                    GraphString.write_graph(mGraph, mVV.getModel().getGraphLayout()));
            text.setEditable(false);
            text.setPreferredSize(new Dimension(300, 125));
            JOptionPane.showMessageDialog(null, text, "GraphString Serialization",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    });

    popup.add(new AbstractAction("Load GraphString") {
        private static final long serialVersionUID = 8636579131902717983L;

        public void actionPerformed(ActionEvent e) {
            String input = JOptionPane.showInputDialog(null, "Enter GraphString:", "");
            if (input == null)
                return;
            loadGraphString(input);
        }
    });

    popup.add(new AbstractAction("Show graph6") {
        private static final long serialVersionUID = 571719411573657792L;

        public void actionPerformed(ActionEvent e) {
            JTextArea text = new JTextArea(Graph6.write_graph6(mGraph));
            JOptionPane.showMessageDialog(null, text, "graph6 Serialization", JOptionPane.INFORMATION_MESSAGE);
        }
    });

    popup.add(new AbstractAction("Load graph6/sparse6") {
        private static final long serialVersionUID = 571719411573657792L;

        public void actionPerformed(ActionEvent e) {
            String input = JOptionPane.showInputDialog(null, "Enter graph6/sparse6 string:", "");
            if (input == null)
                return;
            MyGraph g = Graph6.read_graph6(input);
            setNewGraph(g);
        }
    });

    popup.add(new AbstractAction("Read GraphML") {
        private static final long serialVersionUID = 571719411573657794L;

        public void actionPerformed(ActionEvent e) {
            try {
                readGraphML();
            } catch (IOException e1) {
                showStackTrace(e1);
            } catch (GraphIOException e1) {
                showStackTrace(e1);
            }
        }
    });

    popup.add(new AbstractAction("Write GraphML") {
        private static final long serialVersionUID = 571719411573657795L;

        public void actionPerformed(ActionEvent e) {
            try {
                writeGraphML();
            } catch (IOException e1) {
                showStackTrace(e1);
            }
        }
    });

    popup.add(new AbstractAction("Write PDF") {
        private static final long serialVersionUID = 571719411573657793L;

        public void actionPerformed(ActionEvent e) {
            try {
                writePdf();
            } catch (FileNotFoundException e1) {
                showStackTrace(e1);
            } catch (DocumentException de) {
                System.err.println(de.getMessage());
            }
        }
    });
}

From source file:misc.TextBatchPrintingDemo.java

/**
 * Create and display the main application frame.
 *///from  w w w  .  j  av  a 2s .co m
void createAndShowGUI() {
    messageArea = new JLabel(defaultMessage);

    selectedPages = new JList(new DefaultListModel());
    selectedPages.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    selectedPages.addListSelectionListener(this);

    setPage(homePage);

    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(pageItem),
            new JScrollPane(selectedPages));

    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);

    /** Menu item and keyboard shortcuts for the "add page" command.  */
    fileMenu.add(createMenuItem(new AbstractAction("Add Page") {
        public void actionPerformed(ActionEvent e) {
            DefaultListModel pages = (DefaultListModel) selectedPages.getModel();
            pages.addElement(pageItem);
            selectedPages.setSelectedIndex(pages.getSize() - 1);
        }
    }, KeyEvent.VK_A, KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.ALT_MASK)));

    /** Menu item and keyboard shortcuts for the "print selected" command.*/
    fileMenu.add(createMenuItem(new AbstractAction("Print Selected") {
        public void actionPerformed(ActionEvent e) {
            printSelectedPages();
        }
    }, KeyEvent.VK_P, KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK)));

    /** Menu item and keyboard shortcuts for the "clear selected" command.*/
    fileMenu.add(createMenuItem(new AbstractAction("Clear Selected") {
        public void actionPerformed(ActionEvent e) {
            DefaultListModel pages = (DefaultListModel) selectedPages.getModel();
            pages.removeAllElements();
        }
    }, KeyEvent.VK_C, KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.ALT_MASK)));

    fileMenu.addSeparator();

    /** Menu item and keyboard shortcuts for the "home page" command.  */
    fileMenu.add(createMenuItem(new AbstractAction("Home Page") {
        public void actionPerformed(ActionEvent e) {
            setPage(homePage);
        }
    }, KeyEvent.VK_H, KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK)));

    /** Menu item and keyboard shortcuts for the "quit" command.  */
    fileMenu.add(createMenuItem(new AbstractAction("Quit") {
        public void actionPerformed(ActionEvent e) {
            for (Window w : Window.getWindows()) {
                w.dispose();
            }
        }
    }, KeyEvent.VK_A, KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK)));

    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);

    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    contentPane.add(pane);
    contentPane.add(messageArea);

    JFrame frame = new JFrame("Text Batch Printing Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menuBar);
    frame.setContentPane(contentPane);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    if (printService == null) {
        // Actual printing is not possible, issue a warning message.
        JOptionPane.showMessageDialog(frame, "No default print service", "Print Service Alert",
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:ca.phon.app.project.ProjectWindow.java

@Override
public void setJMenuBar(JMenuBar menu) {
    super.setJMenuBar(menu);

    JMenu projectMenu = new JMenu("Project");

    int projectMenuIndex = -1;
    // get the edit menu and add view commands
    for (int i = 0; i < menu.getMenuCount(); i++) {
        JMenu currentBar = menu.getMenu(i);

        if (currentBar != null && currentBar.getText() != null && currentBar.getText().equals("Workspace")) {
            projectMenuIndex = i + 1;//from   ww  w  . j  av a2 s  .co  m
        }
    }

    if (projectMenuIndex > 0) {
        menu.add(projectMenu, projectMenuIndex);
    }

    // refresh lists 
    final RefreshAction refreshItem = new RefreshAction(this);
    projectMenu.add(refreshItem);
    projectMenu.addSeparator();

    // create corpus item
    final NewCorpusAction newCorpusItem = new NewCorpusAction(this);
    projectMenu.add(newCorpusItem);

    //       create corpus item
    final NewSessionAction newSessionItem = new NewSessionAction(this);
    projectMenu.add(newSessionItem);

    projectMenu.addSeparator();

    final AnonymizeAction anonymizeParticipantInfoItem = new AnonymizeAction(this);
    projectMenu.add(anonymizeParticipantInfoItem);

    final CheckTranscriptionsAction repairItem = new CheckTranscriptionsAction(this);
    projectMenu.add(repairItem);

    // merge/split sessions
    final DeriveSessionAction deriveItem = new DeriveSessionAction(this);
    projectMenu.add(deriveItem);

    final JMenu teamMenu = new JMenu("Team");
    teamMenu.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(MenuEvent e) {
            teamMenu.removeAll();
            if (getProject() != null) {
                final ProjectGitController gitController = new ProjectGitController(getProject());
                if (gitController.hasGitFolder()) {
                    teamMenu.add(new CommitAction(ProjectWindow.this));

                    teamMenu.addSeparator();

                    teamMenu.add(new PullAction(ProjectWindow.this));
                    teamMenu.add(new PushAction(ProjectWindow.this));

                } else {
                    final InitAction initRepoAct = new InitAction(ProjectWindow.this);
                    teamMenu.add(initRepoAct);
                }
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {

        }

        @Override
        public void menuCanceled(MenuEvent e) {

        }
    });
    projectMenu.addSeparator();
    projectMenu.add(teamMenu);
}

From source file:au.org.ala.delta.editor.DeltaEditor.java

private void buildWindowMenu(JMenu mnuWindow) {
    mnuWindow.removeAll();/*from www.j ava 2s.c  o  m*/

    JMenuItem mnuItCascade = new JMenuItem();
    mnuItCascade.setAction(_actionMap.get("cascadeFrames"));
    mnuWindow.add(mnuItCascade);

    JMenuItem mnuItTile = new JMenuItem();
    mnuItTile.setAction(_actionMap.get("tileFrames"));
    mnuWindow.add(mnuItTile);

    JMenuItem mnuItTileHorz = new JMenuItem();
    mnuItTileHorz.setAction(_actionMap.get("tileFramesHorizontally"));
    mnuWindow.add(mnuItTileHorz);

    JMenuItem mnuItArrangeIcons = new JMenuItem();
    mnuItArrangeIcons.setAction(_actionMap.get("arrangeIcons"));
    mnuWindow.add(mnuItArrangeIcons);

    JMenuItem mnuItCloseAll = new JMenuItem();
    mnuItCloseAll.setAction(_actionMap.get("closeAllFrames"));
    mnuWindow.add(mnuItCloseAll);

    mnuWindow.addSeparator();

    JMenuItem mnuItChooseFont = new JMenuItem();
    mnuItChooseFont.setAction(_actionMap.get("chooseFont"));
    mnuWindow.add(mnuItChooseFont);

    mnuWindow.addSeparator();

    JMenu mnuLF = new JMenu();
    mnuLF.setName("mnuLF");
    mnuLF.setText(_resourceMap.getString("mnuLF.text"));
    mnuWindow.add(mnuLF);

    JMenuItem mnuItMetalLF = new JMenuItem();
    mnuItMetalLF.setAction(_actionMap.get("metalLookAndFeel"));
    mnuLF.add(mnuItMetalLF);

    JMenuItem mnuItWindowsLF = new JMenuItem();
    mnuItWindowsLF.setAction(_actionMap.get("systemLookAndFeel"));
    mnuLF.add(mnuItWindowsLF);

    try {
        // Nimbus L&F was added in update java 6 update 10.
        Class.forName("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel").newInstance();
        JMenuItem mnuItNimbusLF = new JMenuItem();
        mnuItNimbusLF.setAction(_actionMap.get("nimbusLookAndFeel"));
        mnuLF.add(mnuItNimbusLF);
    } catch (Exception e) {
        // The Nimbus L&F is not available, no matter.
    }
    mnuWindow.addSeparator();

    int i = 1;
    for (final JInternalFrame frame : _frames) {
        JMenuItem windowItem = new JCheckBoxMenuItem();
        if (i < 10) {
            windowItem.setText(String.format("%d %s", i, frame.getTitle()));
            windowItem.setMnemonic(KeyEvent.VK_1 + (i - 1));
        } else {
            windowItem.setText(frame.getTitle());
        }
        windowItem.setSelected(frame.isSelected());
        windowItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    frame.setSelected(true);
                } catch (PropertyVetoException e1) {
                }
            }
        });
        mnuWindow.add(windowItem);
        ++i;
    }

}

From source file:au.org.ala.delta.editor.DeltaEditor.java

private JMenuBar buildMenus() {

    JMenuBar menuBar = new JMenuBar();

    // File menu. This on is kind of special, in that it gets rebuilt each
    // time a file is opened.
    _fileMenu = new JMenu();
    _fileMenu.setName("mnuFile");
    buildFileMenu(_fileMenu);//www.  j  a  va  2s.  co  m
    menuBar.add(_fileMenu);

    // Edit Menu
    JMenu mnuEdit = buildEditMenu();
    menuBar.add(mnuEdit);

    // Search Menu
    JMenu mnuSearch = buildSearchMenu();
    menuBar.add(mnuSearch);

    // View Menu
    JMenu mnuView = buildViewMenu();

    menuBar.add(mnuView);

    // Window menu
    _windowMenu = new JMenu();
    _windowMenu.setName("mnuWindow");
    buildWindowMenu(_windowMenu);
    menuBar.add(_windowMenu);

    JMenu mnuHelp = new JMenu();
    mnuHelp.setName("mnuHelp");
    JMenuItem mnuItHelpContents = new JMenuItem();
    mnuItHelpContents.setName("mnuItHelpContents");
    mnuHelp.add(mnuItHelpContents);
    mnuItHelpContents.addActionListener(_helpController.helpAction());

    JMenuItem mnuItHelpOnSelection = new JMenuItem(IconHelper.createImageIcon("help_cursor.png"));
    mnuItHelpOnSelection.setName("mnuItHelpOnSelection");

    mnuItHelpOnSelection.addActionListener(_helpController.helpOnSelectionAction());
    mnuHelp.add(mnuItHelpOnSelection);

    javax.swing.Action openAboutAction = _actionMap.get("openAbout");

    if (isMac()) {
        configureMacAboutBox(openAboutAction);
    } else {
        JMenuItem mnuItAbout = new JMenuItem();
        mnuItAbout.setAction(openAboutAction);
        mnuHelp.addSeparator();
        mnuHelp.add(mnuItAbout);
    }
    menuBar.add(mnuHelp);

    return menuBar;
}

From source file:com.digitalgeneralists.assurance.ui.MainWindow.java

private void initializeComponent() {
    if (!this.initialized) {
        logger.info("Initializing the main window.");

        if (AssuranceUtils.getPlatform() == Platform.MAC) {

            System.setProperty("apple.laf.useScreenMenuBar", "true");
            com.apple.eawt.Application macApplication = com.apple.eawt.Application.getApplication();
            MacApplicationAdapter macAdapter = new MacApplicationAdapter(this);
            macApplication.addApplicationListener(macAdapter);
            macApplication.setEnabledPreferencesMenu(true);
        }/*w w  w .ja v  a  2  s  .  c o  m*/

        this.setTitle(Application.applicationShortName);

        this.setDefaultCloseOperation(EXIT_ON_CLOSE);

        GridBagLayout gridbag = new GridBagLayout();
        this.setLayout(gridbag);

        this.topArea = new JTabbedPane();

        this.scanLaunchPanel.setPreferredSize(new Dimension(600, 150));

        this.scanHistoryPanel.setPreferredSize(new Dimension(600, 150));

        this.topArea.addTab("Scan", this.scanLaunchPanel);

        this.topArea.addTab("History", this.scanHistoryPanel);

        this.resultsPanel.setPreferredSize(new Dimension(600, 400));

        this.topArea.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                resultsPanel.resetPanel();
                // NOTE:  This isn't ideal.  It feels brittle.
                if (topArea.getSelectedIndex() == viewHistoryMenuItemIndex) {
                    viewHistoryMenuItem.setSelected(true);
                } else {
                    viewScanMenuItem.setSelected(true);
                }
            }
        });

        GridBagConstraints topPanelConstraints = new GridBagConstraints();
        topPanelConstraints.anchor = GridBagConstraints.NORTH;
        topPanelConstraints.fill = GridBagConstraints.BOTH;
        topPanelConstraints.gridx = 0;
        topPanelConstraints.gridy = 0;
        topPanelConstraints.weightx = 1.0;
        topPanelConstraints.weighty = 0.33;
        topPanelConstraints.gridheight = 1;
        topPanelConstraints.gridwidth = 1;
        topPanelConstraints.insets = new Insets(0, 0, 0, 0);

        this.getContentPane().add(this.topArea, topPanelConstraints);

        GridBagConstraints resultsPanelConstraints = new GridBagConstraints();
        resultsPanelConstraints.anchor = GridBagConstraints.SOUTH;
        resultsPanelConstraints.fill = GridBagConstraints.BOTH;
        resultsPanelConstraints.gridx = 0;
        resultsPanelConstraints.gridy = 1;
        resultsPanelConstraints.weightx = 1.0;
        resultsPanelConstraints.weighty = 0.67;
        resultsPanelConstraints.gridheight = 1;
        resultsPanelConstraints.gridwidth = 1;
        resultsPanelConstraints.insets = new Insets(0, 0, 0, 0);

        this.getContentPane().add(this.resultsPanel, resultsPanelConstraints);

        this.applicationDelegate.addEventObserver(ScanStartedEvent.class, this);
        this.applicationDelegate.addEventObserver(ScanCompletedEvent.class, this);
        this.applicationDelegate.addEventObserver(SetScanDefinitionMenuStateEvent.class, this);
        this.applicationDelegate.addEventObserver(SetScanResultsMenuStateEvent.class, this);
        this.applicationDelegate.addEventObserver(ApplicationConfigurationLoadedEvent.class, this);

        JMenu menu;
        JMenuItem menuItem;

        menuBar = new JMenuBar();

        StringBuilder accessiblityLabel = new StringBuilder(128);
        if (AssuranceUtils.getPlatform() != Platform.MAC) {
            menu = new JMenu(Application.applicationShortName);
            menu.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Actions for ")
                    .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuBar.add(menu);

            menuItem = new JMenuItem(MainWindow.quitApplicationMenuLabel, KeyEvent.VK_Q);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
            menuItem.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Close the ")
                    .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuItem.addActionListener(this);
            menuItem.setActionCommand(AssuranceActions.quitApplicationAction);
            menu.add(menuItem);

            menu.addSeparator();

            menuItem = new JMenuItem(MainWindow.aboutApplicationMenuLabel);
            menuItem.getAccessibleContext().setAccessibleDescription(
                    accessiblityLabel.append("Display information about this version of ")
                            .append(Application.applicationShortName).append(".").toString());
            accessiblityLabel.setLength(0);
            menuItem.addActionListener(this);
            menuItem.setActionCommand(AssuranceActions.aboutApplicationAction);
            menu.add(menuItem);
        }

        menu = new JMenu("Scan");
        menu.setMnemonic(KeyEvent.VK_S);
        menu.getAccessibleContext().setAccessibleDescription("Actions for file scans");
        menuBar.add(menu);

        menuItem = new JMenuItem(MainWindow.newScanDefinitonMenuLabel, KeyEvent.VK_N);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext().setAccessibleDescription("Create a new scan definition");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.newScanDefinitonAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.deleteScanDefinitonMenuLabel, KeyEvent.VK_D);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext().setAccessibleDescription("Delete the selected scan definition");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.deleteScanDefinitonAction);
        menu.add(menuItem);

        menu.addSeparator();

        menuItem = new JMenuItem(MainWindow.scanMenuLabel, KeyEvent.VK_S);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext()
                .setAccessibleDescription("Launch a scan using the selected scan definition");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.scanAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.scanAndMergeMenuLabel, KeyEvent.VK_M);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext().setAccessibleDescription(
                "Launch a scan using the selected scan definition and merge the results");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.scanAndMergeAction);
        menu.add(menuItem);

        menu = new JMenu("Results");
        menu.setMnemonic(KeyEvent.VK_R);
        menu.getAccessibleContext().setAccessibleDescription("Actions for scan results");
        menuBar.add(menu);

        menuItem = new JMenuItem(MainWindow.replaceSourceMenuLabel, KeyEvent.VK_O);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext()
                .setAccessibleDescription("Replace the source file with the target file");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.replaceSourceAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.replaceTargetMenuLabel, KeyEvent.VK_T);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext()
                .setAccessibleDescription("Replace the target file with the source file");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.replaceTargetAction);
        menu.add(menuItem);

        menu.addSeparator();

        menuItem = new JMenuItem(MainWindow.sourceAttributesMenuLabel);
        menuItem.getAccessibleContext().setAccessibleDescription("View the source file attributes");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.sourceAttributesAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.targetAttributesMenuLabel);
        menuItem.getAccessibleContext().setAccessibleDescription("View the target file attributes");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.targetAttributesAction);
        menu.add(menuItem);

        menu = new JMenu("View");
        menu.setMnemonic(KeyEvent.VK_V);
        menu.getAccessibleContext().setAccessibleDescription(
                accessiblityLabel.append("Views within ").append(Application.applicationShortName).toString());
        accessiblityLabel.setLength(0);
        menuBar.add(menu);

        ButtonGroup group = new ButtonGroup();

        this.viewScanMenuItem = new JRadioButtonMenuItem(MainWindow.viewScanMenuLabel);
        this.viewScanMenuItem.addActionListener(this);
        this.viewScanMenuItem.setActionCommand(AssuranceActions.viewScanAction);
        this.viewScanMenuItem.setSelected(true);
        group.add(this.viewScanMenuItem);
        menu.add(this.viewScanMenuItem);

        this.viewHistoryMenuItem = new JRadioButtonMenuItem(MainWindow.viewHistoryMenuLabel);
        this.viewHistoryMenuItem.addActionListener(this);
        this.viewHistoryMenuItem.setActionCommand(AssuranceActions.viewHistoryAction);
        this.viewHistoryMenuItem.setSelected(true);
        group.add(this.viewHistoryMenuItem);
        menu.add(this.viewHistoryMenuItem);

        if (AssuranceUtils.getPlatform() != Platform.MAC) {
            menu = new JMenu("Tools");
            menu.getAccessibleContext()
                    .setAccessibleDescription(accessiblityLabel.append("Additional actions for ")
                            .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuBar.add(menu);

            menuItem = new JMenuItem(MainWindow.settingsMenuLabel, KeyEvent.VK_COMMA);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, ActionEvent.CTRL_MASK));
            menuItem.getAccessibleContext()
                    .setAccessibleDescription(accessiblityLabel.append("Change settings for the ")
                            .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuItem.addActionListener(this);
            menuItem.setActionCommand(AssuranceActions.displaySettingsAction);
            menu.add(menuItem);
        }

        this.setJMenuBar(menuBar);

        this.initialized = true;
    }
}

From source file:gdt.jgui.tool.JTextEditor.java

/**
 * Get context menu.//from w w w.j  a  va  2  s  .  c  o m
 * @return the context menu. 
 */
@Override
public JMenu getContextMenu() {
    JMenu menu = new JMenu("Context");
    JMenuItem doneItem = new JMenuItem("Done");
    doneItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //System.out.println("TextEditor:done:text="+editorPane.getText());
            if (requesterResponseLocator$ != null) {
                try {
                    byte[] ba = Base64.decodeBase64(requesterResponseLocator$);
                    String responseLocator$ = new String(ba, "UTF-8");
                    text$ = editorPane.getText();
                    if (base64)
                        text$ = Locator.compressText(text$);
                    responseLocator$ = Locator.append(responseLocator$, TEXT, text$);
                    System.out.println("TextEditor:done:response locator="
                            + Locator.remove(responseLocator$, Locator.LOCATOR_ICON));
                    JConsoleHandler.execute(console, responseLocator$);
                } catch (Exception ee) {
                    LOGGER.severe(ee.toString());
                }
            } else {
                //System.out.println("TextEditor:done:requester locator is null");
                console.back();
            }
        }
    });
    menu.add(doneItem);
    JMenuItem cancelItem = new JMenuItem("Cancel");
    cancelItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            console.back();
        }
    });
    menu.add(cancelItem);
    menu.addSeparator();
    JMenuItem encryptItem = new JMenuItem("Encrypt/Decrypt");
    encryptItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JTextEncrypter ten = new JTextEncrypter();
            String tenLocator$ = ten.getLocator();
            tenLocator$ = Locator.append(tenLocator$, Entigrator.ENTIHOME, entihome$);
            tenLocator$ = Locator.append(tenLocator$, JTextEditor.TEXT, editorPane.getText());
            String tedLocator$ = getLocator();
            tedLocator$ = Locator.append(tedLocator$, BaseHandler.HANDLER_METHOD, "response");
            tedLocator$ = Locator.append(tedLocator$, JRequester.REQUESTER_ACTION, ACTION_ENCODE_TEXT);
            tenLocator$ = Locator.append(tenLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                    Locator.compressText(tedLocator$));
            JConsoleHandler.execute(console, tenLocator$);
        }
    });
    menu.add(encryptItem);
    return menu;
}

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

/**
 * Creates the view menu.//from   w ww  . j  a  va2s.co m
 *
 * @return the new view menu
 */
protected JMenu createViewMenu() {
    JMenuItem menuItem;
    JMenu viewMenu = new JMenu("View");
    viewMenu.setMnemonic(KeyEvent.VK_V);

    JMenu annoyanceModeMenu = new JMenu("Annoyance Mode");
    annoyanceJordanCheckbox = new JCheckBoxMenuItem("Jordan Mode");
    annoyanceJordanCheckbox.setToolTipText("For Cool People");
    annoyanceJordanCheckbox.setActionCommand(ACTION_ANNOY_JORDAN);
    annoyanceJordanCheckbox.addActionListener(this);
    annoyanceModeMenu.add(annoyanceJordanCheckbox);

    annoyanceDougCheckbox = new JCheckBoxMenuItem("Doug Mode");
    annoyanceDougCheckbox.setToolTipText("For Losers");
    annoyanceJordanCheckbox.setActionCommand(ACTION_ANNOY_DOUG);
    annoyanceDougCheckbox.addActionListener(this);
    annoyanceModeMenu.add(annoyanceDougCheckbox);

    annoyanceNoneCheckbox = new JCheckBoxMenuItem("None");
    annoyanceJordanCheckbox.setActionCommand(ACTION_ANNOY_NONE);
    annoyanceNoneCheckbox.addActionListener(this);
    annoyanceModeMenu.add(annoyanceNoneCheckbox);
    updateAnnoyanceButtons();

    viewMenu.add(annoyanceModeMenu);

    menuItem = new JMenuItem("Refresh View", KeyEvent.VK_R);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menuItem.setActionCommand(ACTION_REFRESH_VIEW);
    menuItem.addActionListener(this);
    viewMenu.add(menuItem);

    viewMenu.addSeparator();

    menuItem = new JMenuItem("Change Start Time");
    menuItem.setActionCommand(ACTION_CHANGE_START);
    menuItem.addActionListener(this);
    viewMenu.add(menuItem);

    menuItem = new JMenuItem("Change Annoy Time");
    // currently disabled experimental functionality
    menuItem.setEnabled(false);
    menuItem.setActionCommand(ACTION_CHANGE_ANNOY);
    menuItem.addActionListener(this);
    viewMenu.add(menuItem);

    viewMenu.addSeparator();

    menuItem = new JMenuItem("Select Previous Tab", KeyEvent.VK_BRACELEFT);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BRACELEFT,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menuItem.setActionCommand(ACTION_PREVIOUS_TAB);
    menuItem.addActionListener(this);
    viewMenu.add(menuItem);

    menuItem = new JMenuItem("Select Next Tab", KeyEvent.VK_BRACERIGHT);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BRACERIGHT,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menuItem.setActionCommand(ACTION_NEXT_TAB);
    menuItem.addActionListener(this);
    viewMenu.add(menuItem);

    return viewMenu;
}