Example usage for java.awt.event KeyEvent VK_F

List of usage examples for java.awt.event KeyEvent VK_F

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_F.

Prototype

int VK_F

To view the source code for java.awt.event KeyEvent VK_F.

Click Source Link

Document

Constant for the "F" key.

Usage

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

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

From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUI.java

/**
 * Helper method to create the <code>File</code> menu.
 * //w  ww  . java 2 s .  c  o  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.orbisgis.groovy.GroovyConsolePanel.java

/**
 * Create actions instances//  w w  w .ja  v  a2s.co m
 *
 * Each action is put in the Popup menu and the tool bar Their shortcuts are
 * registered also in the editor
 */
private void initActions() {
    //Execute action
    executeAction = new DefaultAction(GroovyConsoleActions.A_EXECUTE, I18N.tr("Execute"),
            I18N.tr("Execute the groovy script"), GroovyIcon.getIcon("execute"),
            EventHandler.create(ActionListener.class, this, "onExecute"),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom");
    actions.addAction(executeAction);

    //Execute Selected SQL
    executeSelectedAction = new DefaultAction(GroovyConsoleActions.A_EXECUTE_SELECTION,
            I18N.tr("Execute selected"), I18N.tr("Run selected code"), GroovyIcon.getIcon("execute_selection"),
            EventHandler.create(ActionListener.class, this, "onExecuteSelected"),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.ALT_DOWN_MASK)).setLogicalGroup("custom")
                    .setAfter(GroovyConsoleActions.A_EXECUTE);
    actions.addAction(executeSelectedAction);

    //Clear action
    clearAction = new DefaultAction(GroovyConsoleActions.A_CLEAR, I18N.tr("Clear"),
            I18N.tr("Erase the content of the editor"), GroovyIcon.getIcon("erase"),
            EventHandler.create(ActionListener.class, this, "onClear"), null);
    actions.addAction(clearAction);

    //Open action
    actions.addAction(new DefaultAction(GroovyConsoleActions.A_OPEN, I18N.tr("Open"),
            I18N.tr("Load a file in this editor"), GroovyIcon.getIcon("open"),
            EventHandler.create(ActionListener.class, this, "onOpenFile"),
            KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)));
    //Save
    saveAction = new DefaultAction(GroovyConsoleActions.A_SAVE, I18N.tr("Save"),
            I18N.tr("Save the editor content into a file"), GroovyIcon.getIcon("save"),
            EventHandler.create(ActionListener.class, this, "onSaveFile"),
            KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
    actions.addAction(saveAction);
    // Save As
    saveAsAction = new DefaultAction(GroovyConsoleActions.A_SAVE, I18N.tr("Save As"),
            I18N.tr("Save the editor content into a new file"), GroovyIcon.getIcon("page_white_save"),
            EventHandler.create(ActionListener.class, this, "onSaveAsNewFile"),
            KeyStroke.getKeyStroke("ctrl maj s"));
    actions.addAction(saveAsAction);
    //Find action
    findAction = new DefaultAction(GroovyConsoleActions.A_SEARCH, I18N.tr("Search.."),
            I18N.tr("Search text in the document"), GroovyIcon.getIcon("find"),
            EventHandler.create(ActionListener.class, this, "openFindReplaceDialog"),
            KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK))
                    .addStroke(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK));
    actions.addAction(findAction);

    // Comment/Uncomment
    commentAction = new DefaultAction(GroovyConsoleActions.A_COMMENT, I18N.tr("(Un)comment"),
            I18N.tr("(Un)comment the selected text"), null,
            EventHandler.create(ActionListener.class, this, "onComment"), KeyStroke.getKeyStroke("alt C"))
                    .setLogicalGroup("format");
    actions.addAction(commentAction);

    // Block Comment/Uncomment
    blockCommentAction = new DefaultAction(GroovyConsoleActions.A_BLOCKCOMMENT, I18N.tr("Block (un)comment"),
            I18N.tr("Block (un)comment the selected text."), null,
            EventHandler.create(ActionListener.class, this, "onBlockComment"),
            KeyStroke.getKeyStroke("alt shift C")).setLogicalGroup("format");
    actions.addAction(blockCommentAction);
}

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

/**
 * Creates the task menu./*w ww  .  ja v  a2 s.c  om*/
 *
 * @return the new task menu
 */
protected JMenu createTaskMenu() {
    JMenuItem menuItem;
    JMenu taskMenu = new JMenu("Task");
    taskMenu.setMnemonic(KeyEvent.VK_T);
    this.add(taskMenu);

    menuItem = new JMenuItem("New Task", KeyEvent.VK_N);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menuItem.setActionCommand(ACTION_ADDTASK);
    menuItem.addActionListener(this);
    taskMenu.add(menuItem);

    menuItem = new JMenuItem("Hide Old Tasks", KeyEvent.VK_H);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_H, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menuItem.setActionCommand(ACTION_HIDETASK);
    menuItem.addActionListener(this);
    taskMenu.add(menuItem);

    menuItem = new JMenuItem("Unhide Task", KeyEvent.VK_U);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_U, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menuItem.setActionCommand(ACTION_UNHIDETASK);
    menuItem.addActionListener(this);
    taskMenu.add(menuItem);

    taskMenu.addSeparator();

    menuItem = new JMenuItem("Add Time", KeyEvent.VK_A);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menuItem.setActionCommand(ACTION_ADDTIME);
    menuItem.addActionListener(this);
    taskMenu.add(menuItem);

    menuItem = new JMenuItem("Find Task", KeyEvent.VK_F);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menuItem.setActionCommand(ACTION_FINDTASK);
    menuItem.addActionListener(this);
    taskMenu.add(menuItem);

    return taskMenu;
}

From source file:com.emental.mindraider.ui.frames.MindRaiderMainWindow.java

/**
 * Build main menu./*from w w w .j  a  va 2  s  .com*/
 * 
 * @param spiders
 */
private void buildMenu(final SpidersGraph spiders) {
    JMenuBar menuBar;
    JMenu menu, submenu;
    JMenuItem menuItem, subMenuItem;
    JRadioButtonMenuItem rbMenuItem;

    // create the menu bar
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    // - main menu -------------------------------------------------------
    menu = new JMenu(MindRaiderConstants.MR_TITLE);
    menu.setMnemonic(KeyEvent.VK_M);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.setActiveNotebookAsHome"));
    menuItem.setMnemonic(KeyEvent.VK_H);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            MindRaider.profile.setHomeNotebook();
        }
    });
    menu.add(menuItem);
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.preferences"));
    menuItem.setMnemonic(KeyEvent.VK_P);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            new PreferencesJDialog();
        }
    });
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.exit"), KeyEvent.VK_X);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            exitMindRaider();
        }
    });
    menu.add(menuItem);

    menuBar.add(menu);

    // - Find ----------------------------------------------------------

    menu = new JMenu(Messages.getString("MindRaiderJFrame.search"));
    menu.setMnemonic(KeyEvent.VK_F);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchNotebooks"));
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new OpenOutlineJDialog();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchFulltext"));
    menuItem.setMnemonic(KeyEvent.VK_F);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.setEnabled(true);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new FtsJDialog();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchConceptsInNotebook"));
    menuItem.setMnemonic(KeyEvent.VK_C);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (MindRaider.profile.getActiveOutlineUri() != null) {
                new OpenNoteJDialog();
            }
        }
    });
    menu.add(menuItem);

    // search by tag
    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchConceptsByTag"));
    menuItem.setEnabled(true);
    menuItem.setMnemonic(KeyEvent.VK_T);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            new OpenConceptByTagJDialog();
        }
    });
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.previousNote"));
    menuItem.setEnabled(true);
    menuItem.setMnemonic(KeyEvent.VK_P);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.ALT_MASK));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            MindRaider.recentConcepts.moveOneNoteBack();
        }
    });
    menu.add(menuItem);

    // global RDF search
    //        menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchRdql"));
    //        menuItem.setEnabled(false);
    //        menuItem.setMnemonic(KeyEvent.VK_R);
    //        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,
    //                ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    //        menuItem.addActionListener(new ActionListener() {
    //
    //            public void actionPerformed(ActionEvent e) {
    //                // TODO rdql to be implemented
    //            }
    //        });
    //        menu.add(menuItem);

    menuBar.add(menu);

    // - view ------------------------------------------------------------
    menu = new JMenu(Messages.getString("MindRaiderJFrame.view"));
    menu.setMnemonic(KeyEvent.VK_V);

    // TODO localize L&F menu
    ButtonGroup lfGroup = new ButtonGroup();
    submenu = new JMenu(Messages.getString("MindRaiderJFrame.lookAndFeel"));
    logger.debug("Look and feel is: " + MindRaider.profile.getLookAndFeel()); // {{debug}}
    submenu.setMnemonic(KeyEvent.VK_L);
    subMenuItem = new JRadioButtonMenuItem(Messages.getString("MindRaiderJFrame.lookAndFeelNative"));
    if (MindRaider.LF_NATIVE.equals(MindRaider.profile.getLookAndFeel())) {
        subMenuItem.setSelected(true);
    }
    subMenuItem.setEnabled(true);
    subMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            setLookAndFeel(MindRaider.LF_NATIVE);
        }
    });
    submenu.add(subMenuItem);
    lfGroup.add(subMenuItem);
    subMenuItem = new JRadioButtonMenuItem(Messages.getString("MindRaiderJFrame.lookAndFeelJava"));
    if (MindRaider.LF_JAVA_DEFAULT.equals(MindRaider.profile.getLookAndFeel())) {
        subMenuItem.setSelected(true);
    }
    subMenuItem.setEnabled(true);
    subMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            setLookAndFeel(MindRaider.LF_JAVA_DEFAULT);
        }
    });
    submenu.add(subMenuItem);
    lfGroup.add(subMenuItem);
    menu.add(submenu);

    menu.addSeparator();
    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.leftSideBar"));
    menuItem.setMnemonic(KeyEvent.VK_L);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (leftSidebarSplitPane.getDividerLocation() == 1) {
                leftSidebarSplitPane.resetToPreferredSizes();
            } else {
                closeLeftSidebar();
            }
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rightSideBar"));
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            OutlineJPanel.getInstance().toggleRightSidebar();
        }
    });
    menu.add(menuItem);

    // TODO tips to be implemented
    // JCheckBoxMenuItem helpCheckbox=new JCheckBoxMenuItem("Tips",true);
    // menu.add(helpCheckbox);

    // TODO localize
    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.toolbar"));
    menuItem.setMnemonic(KeyEvent.VK_T);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            MindRaider.masterToolBar.toggleVisibility();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rdfNavigatorDashboard"));
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            MindRaider.spidersGraph.getGlPanel().toggleControlPanel();
        }
    });
    menu.add(menuItem);

    JCheckBoxMenuItem checkboxMenuItem;
    ButtonGroup colorSchemeGroup;

    //        if (!MindRaider.OUTLINER_PERSPECTIVE.equals(MindRaider.profile
    //                .getUiPerspective())) {

    menu.addSeparator();

    // Facets
    submenu = new JMenu(Messages.getString("MindRaiderJFrame.facet"));
    submenu.setMnemonic(KeyEvent.VK_F);
    colorSchemeGroup = new ButtonGroup();

    String[] facetLabels = FacetCustodian.getInstance().getFacetLabels();
    if (!ArrayUtils.isEmpty(facetLabels)) {
        for (String facetLabel : facetLabels) {
            rbMenuItem = new JRadioButtonMenuItem(facetLabel);
            rbMenuItem.addActionListener(new FacetActionListener(facetLabel));
            colorSchemeGroup.add(rbMenuItem);
            submenu.add(rbMenuItem);
            if (BriefFacet.LABEL.equals(facetLabel)) {
                rbMenuItem.setSelected(true);
            }
        }

    }
    menu.add(submenu);

    checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.graphLabelAsUri"));
    checkboxMenuItem.setMnemonic(KeyEvent.VK_G);
    checkboxMenuItem.setState(MindRaider.spidersGraph.isUriLabels());
    checkboxMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JCheckBoxMenuItem) {
                JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource();
                MindRaider.spidersGraph.setUriLabels(j.getState());
                MindRaider.spidersGraph.renderModel();
                MindRaider.profile.setGraphShowLabelsAsUris(j.getState());
                MindRaider.profile.save();
            }
        }
    });

    menu.add(checkboxMenuItem);

    checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.predicateNodes"));
    checkboxMenuItem.setMnemonic(KeyEvent.VK_P);
    checkboxMenuItem.setState(!MindRaider.spidersGraph.getHidePredicates());
    checkboxMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JCheckBoxMenuItem) {
                JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource();
                MindRaider.spidersGraph.hidePredicates(!j.getState());
                MindRaider.spidersGraph.renderModel();
                MindRaider.profile.setGraphHidePredicates(!j.getState());
                MindRaider.profile.save();
            }
        }
    });
    menu.add(checkboxMenuItem);

    checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.multilineLabels"));
    checkboxMenuItem.setMnemonic(KeyEvent.VK_M);
    checkboxMenuItem.setState(MindRaider.spidersGraph.isMultilineNodes());
    checkboxMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JCheckBoxMenuItem) {
                JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource();
                MindRaider.spidersGraph.setMultilineNodes(j.getState());
                MindRaider.spidersGraph.renderModel();
                MindRaider.profile.setGraphMultilineLabels(j.getState());
                MindRaider.profile.save();
            }
        }
    });
    menu.add(checkboxMenuItem);
    //        }

    menu.addSeparator();

    // Antialias
    checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.antiAliased"), true);
    checkboxMenuItem.setMnemonic(KeyEvent.VK_A);
    checkboxMenuItem.setState(SpidersGraph.antialiased);
    checkboxMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JCheckBoxMenuItem) {
                JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource();
                SpidersGraph.antialiased = j.getState();
                MindRaider.spidersGraph.renderModel();
            }
        }
    });
    menu.add(checkboxMenuItem);

    // Enable hyperbolic
    checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.hyperbolic"), true);
    checkboxMenuItem.setMnemonic(KeyEvent.VK_H);
    checkboxMenuItem.setState(SpidersGraph.hyperbolic);
    checkboxMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JCheckBoxMenuItem) {
                JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource();
                SpidersGraph.hyperbolic = j.getState();
                MindRaider.spidersGraph.renderModel();
            }
        }
    });
    menu.add(checkboxMenuItem);

    // Show FPS
    checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.fps"), true);
    checkboxMenuItem.setMnemonic(KeyEvent.VK_F);
    checkboxMenuItem.setState(SpidersGraph.fps);
    checkboxMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JCheckBoxMenuItem) {
                JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource();
                SpidersGraph.fps = j.getState();
                MindRaider.spidersGraph.renderModel();
            }
        }
    });
    menu.add(checkboxMenuItem);

    // Graph color scheme
    submenu = new JMenu(Messages.getString("MindRaiderJFrame.colorScheme"));
    submenu.setMnemonic(KeyEvent.VK_C);
    String[] allProfilesUris = MindRaider.spidersColorProfileRegistry.getAllProfilesUris();
    colorSchemeGroup = new ButtonGroup();
    for (int i = 0; i < allProfilesUris.length; i++) {
        rbMenuItem = new UriJRadioButtonMenuItem(
                MindRaider.spidersColorProfileRegistry.getColorProfileByUri(allProfilesUris[i]).getLabel(),
                allProfilesUris[i]);
        rbMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (e.getSource() instanceof UriJRadioButtonMenuItem) {
                    MindRaider.spidersColorProfileRegistry
                            .setCurrentProfile(((UriJRadioButtonMenuItem) e.getSource()).uri);
                    MindRaider.spidersGraph
                            .setRenderingProfile(MindRaider.spidersColorProfileRegistry.getCurrentProfile());
                    MindRaider.spidersGraph.renderModel();
                }
            }
        });
        colorSchemeGroup.add(rbMenuItem);
        submenu.add(rbMenuItem);
    }
    menu.add(submenu);

    // Annotation color scheme
    submenu = new JMenu(Messages.getString("MindRaiderJFrame.colorSchemeAnnotation"));
    submenu.setMnemonic(KeyEvent.VK_A);
    allProfilesUris = MindRaider.annotationColorProfileRegistry.getAllProfilesUris();
    colorSchemeGroup = new ButtonGroup();
    for (int i = 0; i < allProfilesUris.length; i++) {
        rbMenuItem = new UriJRadioButtonMenuItem(
                MindRaider.annotationColorProfileRegistry.getColorProfileByUri(allProfilesUris[i]).getLabel(),
                allProfilesUris[i]);
        rbMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (e.getSource() instanceof UriJRadioButtonMenuItem) {
                    MindRaider.annotationColorProfileRegistry
                            .setCurrentProfile(((UriJRadioButtonMenuItem) e.getSource()).uri);
                    OutlineJPanel.getInstance().conceptJPanel.refresh();
                }
            }
        });
        colorSchemeGroup.add(rbMenuItem);
        submenu.add(rbMenuItem);
    }
    menu.add(submenu);

    menu.addSeparator();

    checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.fullScreen"));
    checkboxMenuItem.setMnemonic(KeyEvent.VK_U);
    checkboxMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0));
    checkboxMenuItem.setState(false);
    checkboxMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JCheckBoxMenuItem) {
                JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource();
                if (j.getState()) {
                    Gfx.toggleFullScreen(MindRaiderMainWindow.this);
                } else {
                    Gfx.toggleFullScreen(null);
                }
            }
        }
    });
    menu.add(checkboxMenuItem);

    menuBar.add(menu);

    // - outline
    // ----------------------------------------------------------------------
    menu = new JMenu(Messages.getString("MindRaiderJFrame.notebook"));
    menu.setMnemonic(KeyEvent.VK_N);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.newNotebook"));
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            // TODO clear should be optional - only if creation finished
            // MindRider.spidersGraph.clear();
            new NewOutlineJDialog();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.open"));
    menuItem.setMnemonic(KeyEvent.VK_O);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            new OpenOutlineJDialog();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.close"));
    menuItem.setMnemonic(KeyEvent.VK_C);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            MindRaider.outlineCustodian.close();
            OutlineJPanel.getInstance().refresh();
            MindRaider.spidersGraph.renderModel();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.discard"));
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.setEnabled(false); // TODO discard method must be implemented
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int result = JOptionPane.showConfirmDialog(MindRaiderMainWindow.this, Messages.getString(
                    "MindRaiderJFrame.confirmDiscardNotebook", MindRaider.profile.getActiveOutline()));
            if (result == JOptionPane.YES_OPTION) {
                if (MindRaider.profile.getActiveOutlineUri() != null) {
                    try {
                        MindRaider.labelCustodian
                                .discardOutline(MindRaider.profile.getActiveOutlineUri().toString());
                        MindRaider.outlineCustodian.close();
                    } catch (Exception e1) {
                        logger.error(Messages.getString("MindRaiderJFrame.unableToDiscardNotebook"), e1);
                    }
                }
            }
        }
    });
    menu.add(menuItem);

    menu.addSeparator();

    // export
    submenu = new JMenu(Messages.getString("MindRaiderJFrame.export"));
    submenu.setMnemonic(KeyEvent.VK_E);
    // Atom
    subMenuItem = new JMenuItem("Atom");
    subMenuItem.setEnabled(true);
    subMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            exportActiveOutlineToAtom();
        }
    });
    submenu.add(subMenuItem);

    // OPML
    subMenuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.opml"));
    subMenuItem.setEnabled(true);
    subMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (MindRaider.profile.getActiveOutline() == null) {
                JOptionPane.showMessageDialog(MindRaiderMainWindow.this,
                        Messages.getString("MindRaiderJFrame.exportNotebookWarning"),
                        Messages.getString("MindRaiderJFrame.exportError"),

                        JOptionPane.ERROR_MESSAGE);
                return;
            }

            JFileChooser fc = new JFileChooser();
            fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.export"));
            fc.setControlButtonsAreShown(true);
            fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseExportDirectory"));
            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            // prepare directory
            String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export"
                    + File.separator + "opml";
            Utils.createDirectory(exportDirectory);
            fc.setCurrentDirectory(new File(exportDirectory));
            int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                String dstFileName = fc.getSelectedFile().getAbsolutePath() + File.separator + "OPML-EXPORT-"
                        + MindRaider.outlineCustodian.getActiveNotebookNcName() + ".xml";
                logger.debug(Messages.getString("MindRaiderJFrame.exportingToFile", dstFileName));
                MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_OPML, dstFileName);
                Launcher.launchViaStart(dstFileName);
            } else {
                logger.debug(Messages.getString("MindRaiderJFrame.exportCommandCancelledByUser"));
            }
        }
    });
    submenu.add(subMenuItem);
    // TWiki
    subMenuItem = new JMenuItem("TWiki");
    subMenuItem.setEnabled(true);
    subMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (MindRaider.profile.getActiveOutline() == null) {
                JOptionPane.showMessageDialog(MindRaiderMainWindow.this,
                        Messages.getString("MindRaiderJFrame.exportNotebookWarning"),
                        Messages.getString("MindRaiderJFrame.exportError"), JOptionPane.ERROR_MESSAGE);
                return;
            }

            JFileChooser fc = new JFileChooser();
            fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.export"));
            fc.setControlButtonsAreShown(true);
            fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseExportDirectory"));
            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            // prepare directory
            String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export"
                    + File.separator + "twiki";
            Utils.createDirectory(exportDirectory);
            fc.setCurrentDirectory(new File(exportDirectory));
            int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                final String dstFileName = fc.getSelectedFile().getAbsolutePath() + File.separator
                        + "TWIKI-EXPORT-" + MindRaider.outlineCustodian.getActiveNotebookNcName() + ".txt";
                logger.debug(Messages.getString("MindRaiderJFrame.exportingToFile", dstFileName));

                MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_TWIKI, dstFileName);
            } else {
                logger.debug(Messages.getString("MindRaiderJFrame.exportCommandCancelledByUser"));
            }
        }
    });
    submenu.add(subMenuItem);

    menu.add(submenu);

    // import
    submenu = new JMenu(Messages.getString("MindRaiderJFrame.import"));
    submenu.setMnemonic(KeyEvent.VK_I);

    subMenuItem = new JMenuItem("Atom");
    subMenuItem.setEnabled(true);
    subMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            importFromAtom();
        }
    });
    submenu.add(subMenuItem);

    // TWiki
    subMenuItem = new JMenuItem("TWiki");
    subMenuItem.setEnabled(true);
    subMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            // choose file to be transformed
            OutlineJPanel.getInstance().clear();
            MindRaider.profile.setActiveOutlineUri(null);
            JFileChooser fc = new JFileChooser();
            int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                final File file = fc.getSelectedFile();
                MindRaider.profile.deleteActiveModel();
                logger.debug(
                        Messages.getString("MindRaiderJFrame.importingTWikiTopic", file.getAbsolutePath()));

                // perform it async
                final SwingWorker worker = new SwingWorker() {

                    public Object construct() {
                        ProgressDialogJFrame progressDialogJFrame = new ProgressDialogJFrame(
                                Messages.getString("MindRaiderJFrame.twikiImport"),
                                Messages.getString("MindRaiderJFrame.processingTopicTWiki"));
                        try {
                            MindRaider.outlineCustodian.importNotebook(OutlineCustodian.FORMAT_TWIKI,
                                    (file != null ? file.getAbsolutePath() : null), progressDialogJFrame);
                        } finally {
                            if (progressDialogJFrame != null) {
                                progressDialogJFrame.dispose();
                            }
                        }
                        return null;
                    }
                };
                worker.start();
            } else {
                logger.debug(Messages.getString("MindRaiderJFrame.openCommandCancelledByUser"));
            }
        }
    });
    submenu.add(subMenuItem);

    menu.add(submenu);

    menuBar.add(menu);

    // - note
    // ----------------------------------------------------------------------
    menu = new JMenu(Messages.getString("MindRaiderJFrame.concept"));
    menu.setMnemonic(KeyEvent.VK_C);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.new"));
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            OutlineJPanel.getInstance().newConcept();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.open"));
    menuItem.setMnemonic(KeyEvent.VK_O);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (MindRaider.profile.getActiveOutlineUri() != null) {
                new OpenNoteJDialog();
            }
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.discard"));
    // do not accelerate this command with DEL - it's already handled
    // elsewhere
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            OutlineJPanel.getInstance().conceptDiscard();
        }
    });
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.up"));
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, ActionEvent.CTRL_MASK));
    menuItem.setEnabled(true);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            OutlineJPanel.getInstance().conceptUp();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.promote"));
    menuItem.setMnemonic(KeyEvent.VK_P);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.CTRL_MASK));
    menuItem.setEnabled(true);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            OutlineJPanel.getInstance().conceptPromote();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.demote"));
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ActionEvent.CTRL_MASK));
    menuItem.setEnabled(true);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            OutlineJPanel.getInstance().conceptDemote();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.down"));
    menuItem.setMnemonic(KeyEvent.VK_O);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, ActionEvent.CTRL_MASK));
    menuItem.setEnabled(true);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            OutlineJPanel.getInstance().conceptDown();
        }
    });
    menu.add(menuItem);

    menuBar.add(menu);

    // - Tools -----------------------------------------------------------

    menu = new JMenu(Messages.getString("MindRaiderJFrame.tools"));
    menu.setMnemonic(KeyEvent.VK_T);

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.checkAndFix"));
    menuItem.setMnemonic(KeyEvent.VK_F);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Checker.checkAndFixRepositoryAsync();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.backupRepository"));
    menuItem.setMnemonic(KeyEvent.VK_B);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Installer.backupRepositoryAsync();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rebuildSearchIndex"));
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SearchCommander.rebuildSearchAndTagIndices();
        }
    });
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.captureScreen"));
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fc = new JFileChooser();
            fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.screenshot"));
            fc.setControlButtonsAreShown(true);
            fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseScreenshotDirectory"));
            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            // prepare directory
            String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "Screenshots";
            Utils.createDirectory(exportDirectory);
            fc.setCurrentDirectory(new File(exportDirectory));
            int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                final String filename = fc.getSelectedFile().getAbsolutePath() + File.separator
                        + "screenshot.jpg";

                // do it in async (redraw screen)
                Thread thread = new Thread() {
                    public void run() {
                        OutputStream file = null;
                        try {
                            file = new FileOutputStream(filename);

                            Robot robot = new Robot();
                            robot.delay(1000);

                            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(file);
                            encoder.encode(robot.createScreenCapture(
                                    new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())));
                        } catch (Exception e1) {
                            logger.error("Unable to capture screen!", e1);
                        } finally {
                            if (file != null) {
                                try {
                                    file.close();
                                } catch (IOException e1) {
                                    logger.error("Unable to close stream", e1);
                                }
                            }
                        }
                    }
                };
                thread.setDaemon(true);
                thread.start();

            }
        }
    });
    menu.add(menuItem);

    menuBar.add(menu);

    // - MindForger -----------------------------------------------------------

    menu = new JMenu(Messages.getString("MindRaiderMainWindow.menuMindForger"));
    menu.setMnemonic(KeyEvent.VK_O);
    //menu.setIcon(IconsRegistry.getImageIcon("tasks-internet.png"));

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerVideoTutorial"));
    menuItem.setMnemonic(KeyEvent.VK_G);
    menuItem.setToolTipText("http://mindraider.sourceforge.net/mindforger.html");
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Launcher.launchInBrowser("http://mindraider.sourceforge.net/mindforger.html");
        }
    });
    menuItem.setEnabled(true);
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.signUp"));
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.setToolTipText("http://www.mindforger.com");
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Launcher.launchInBrowser("http://www.mindforger.com");
        }
    });
    menuItem.setEnabled(true);
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerUpload"));
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // fork in order to enable status updates in the main window
            new MindForgerUploadOutlineJDialog();
        }
    });
    menuItem.setEnabled(true);
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerDownload"));
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            downloadAnOutlineFromMindForger();
        }
    });
    menuItem.setEnabled(true);
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerMyOutlines"));
    menuItem.setMnemonic(KeyEvent.VK_O);
    menuItem.setEnabled(true);
    menuItem.setToolTipText("http://web.mindforger.com");
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Launcher.launchInBrowser("http://web.mindforger.com");
        }
    });
    menu.add(menuItem);

    menuBar.add(menu);

    // - align Help on right -------------------------------------------------------------

    menuBar.add(Box.createHorizontalGlue());

    // - help -------------------------------------------------------------
    menu = new JMenu(Messages.getString("MindRaiderJFrame.help"));
    menu.setMnemonic(KeyEvent.VK_H);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.documentation"));
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                MindRaider.outlineCustodian.loadOutline(new URI(MindRaiderVocabulary
                        .getNotebookUri(OutlineCustodian.MR_DOC_NOTEBOOK_DOCUMENTATION_LOCAL_NAME)));
                OutlineJPanel.getInstance().refresh();
            } catch (Exception e1) {
                logger.error(Messages.getString("MindRaiderJFrame.unableToLoadHelp", e1.getMessage()));
            }
        }
    });
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.webHomepage"));
    menuItem.setMnemonic(KeyEvent.VK_H);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Launcher.launchInBrowser("http://mindraider.sourceforge.net");
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.reportBug"));
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Launcher.launchInBrowser("http://sourceforge.net/forum/?group_id=128454");
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.updateCheck"));
    menuItem.setMnemonic(KeyEvent.VK_F);
    menuItem.setEnabled(true);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // just open html page at:
            //   http://mindraider.sourceforge.net/update-7.2.html
            // this page will either contain "you have the last version" or will ask user to
            // download the latest version from main page
            Launcher.launchInBrowser("http://mindraider.sourceforge.net/" + "update-"
                    + MindRaiderConstants.majorVersion + "." + MindRaiderConstants.minorVersion + ".html");
        }
    });
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.about", MindRaiderConstants.MR_TITLE));
    menuItem.setMnemonic(KeyEvent.VK_A);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            new AboutJDialog();
        }
    });
    menu.add(menuItem);

    menuBar.add(menu);
}

From source file:edu.harvard.mcz.imagecapture.encoder.UnitTrayLabelBrowser.java

/**
 * This method initializes jMenu1   // w  w w  .j  a  va  2 s.  co  m
 *    
 * @return javax.swing.JMenu   
 */
private JMenu getJMenu1() {
    if (jMenu1 == null) {
        jMenu1 = new JMenu();
        jMenu1.setText("File");
        jMenu1.setMnemonic(KeyEvent.VK_F);
        jMenu1.add(getJMenuItem3());
        jMenu1.add(getJMenuItem2());
    }
    return jMenu1;
}

From source file:com.qawaa.gui.EventWebScanGUI.java

/**
 * ??//from w ww  . j a  v a2s .  c  o  m
 */
private static void setConsoleRight() {
    consoleRight = new JPopupMenu();
    consoleRight.setBorderPainted(true);
    consoleRight.setPopupSize(new Dimension(105, 135));
    JMenuItem clear = new JMenuItem(CONTEXT.getMessage("gobal.right.menu.clear", null, Locale.CHINA),
            KeyEvent.VK_L);
    JMenuItem copy = new JMenuItem(CONTEXT.getMessage("gobal.right.menu.copy", null, Locale.CHINA),
            KeyEvent.VK_C);
    JMenuItem cut = new JMenuItem(CONTEXT.getMessage("gobal.right.menu.cut", null, Locale.CHINA),
            KeyEvent.VK_X);
    JMenuItem font = new JMenuItem(CONTEXT.getMessage("gobal.right.menu.font", null, Locale.CHINA),
            KeyEvent.VK_F);
    JMenuItem choose = new JMenuItem(CONTEXT.getMessage("gobal.right.menu.choose", null, Locale.CHINA),
            KeyEvent.VK_O);
    JMenuItem saveas = new JMenuItem(CONTEXT.getMessage("gobal.right.menu.saveas", null, Locale.CHINA),
            KeyEvent.VK_S);
    consoleRight.add(clear);
    consoleRight.add(copy);
    consoleRight.add(cut);
    consoleRight.add(font);
    consoleRight.add(choose);
    consoleRight.add(saveas);
    clear.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            consolePane.setText("");
            jConsole.clear();
        }
    });
    copy.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (consolePane.getText() != null && !consolePane.getText().trim().isEmpty()) {
                Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
                Transferable tText = new StringSelection(consolePane.getText());
                clip.setContents(tText, null);
            }

        }
    });
    cut.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (consolePane.getText() != null && !consolePane.getText().trim().isEmpty()) {
                Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
                Transferable tText = new StringSelection(consolePane.getText());
                clip.setContents(tText, null);
            }
            consolePane.setText("");
            jConsole.clear();
        }
    });
    saveas.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser = new JFileChooser();
            int option = fileChooser.showSaveDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                File file = fileChooser.getSelectedFile();
                try {
                    if (file.exists() == false) {
                        file.createNewFile();
                    }
                    FileWriter writer = new FileWriter(file);
                    char[] arry = consolePane.getText().toCharArray();
                    writer.write(arry);
                    writer.flush();
                    writer.close();
                    LOG.info(CONTEXT.getMessage("gobal.right.menu.saveas.success", null, Locale.CHINA));
                } catch (IOException ioe) {
                }
            }
        }
    });
}

From source file:org.photovault.swingui.BrowserWindow.java

protected void createUI(PhotoCollection collection) {
    window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    tabPane = new JTabbedPane();
    queryPane = new QueryPane();
    PhotoFolderTreeController treeCtrl = new PhotoFolderTreeController(window, this);
    viewCtrl = new PhotoViewController(window, this);
    treePane = treeCtrl.folderTree;/*from w ww .j  a v a  2  s.co  m*/
    viewPane = viewCtrl.getThumbPane();
    previewPane = viewCtrl.getPreviewPane();
    tabPane.addTab("Query", queryPane);
    tabPane.addTab("Folders", treePane);

    VolumeTreeController volTreeCtrl = new VolumeTreeController(this);
    JTree volumeTree = volTreeCtrl.getView();
    JScrollPane voltreeScrollPane = new JScrollPane(volumeTree);
    voltreeScrollPane.setPreferredSize(new Dimension(200, 500));
    tabPane.add("Volumes", voltreeScrollPane);

    // TODO: get rid of this!!!!
    EditSelectionColorsAction colorAction = (EditSelectionColorsAction) viewPane.getEditSelectionColorsAction();
    colorAction.setPreviewCtrl(previewPane);

    // Set listeners to both query and folder tree panes

    /*
    If an actionEvent comes from query pane, swich to query results.
     */
    queryPane.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            viewCtrl.setCollection(queryPane.getResultCollection());
        }
    });

    /*
    If the selected folder is changed in treePane, switch to that immediately
     */

    treeCtrl.registerEventListener(PhotoFolderTreeEvent.class, new DefaultEventListener<PhotoCollection>() {

        public void handleEvent(DefaultEvent<PhotoCollection> event) {
            PhotoCollection c = event.getPayload();
            if (c != null) {
                viewCtrl.setCollection(c);
                if (c instanceof PhotoFolder) {
                    PhotoFolder f = (PhotoFolder) c;

                    if (f.getExternalDir() != null) {
                        ExternalDir ed = f.getExternalDir();
                        folderIndexer.updateDir(ed.getVolume(), ed.getPath());
                        viewCtrl.setIndexingOngoing(true);
                    }
                }
            }
        }
    });

    volTreeCtrl.registerEventListener(PhotoFolderTreeEvent.class, new DefaultEventListener<PhotoCollection>() {

        public void handleEvent(DefaultEvent<PhotoCollection> event) {
            PhotoCollection c = event.getPayload();
            if (c != null) {
                viewCtrl.setCollection(c);
                if (c instanceof ExtDirPhotos) {
                    ExtDirPhotos photos = (ExtDirPhotos) c;
                    ExternalVolume vol = (ExternalVolume) viewCtrl.getDAOFactory().getVolumeDAO()
                            .getVolume(photos.getVolId());
                    folderIndexer.updateDir(vol, photos.getDirPath());
                    viewCtrl.setIndexingOngoing(true);
                }
            }
        }
    });

    collectionPane = viewCtrl.getCollectionPane();

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tabPane, collectionPane);
    split.putClientProperty(JSplitPane.ONE_TOUCH_EXPANDABLE_PROPERTY, new Boolean(true));
    Container cp = window.getContentPane();
    cp.setLayout(new BorderLayout());
    cp.add(split, BorderLayout.CENTER);

    statusBar = new StatusBar();
    cp.add(statusBar, BorderLayout.SOUTH);

    // Create actions for BrowserWindow UI

    ImageIcon indexDirIcon = getIcon("index_dir.png");
    DefaultAction indexDirAction = new DefaultAction("Index directory...", indexDirIcon) {

        public void actionPerformed(ActionEvent e) {
            indexDir();
        }
    };
    indexDirAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_D);
    indexDirAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Index all images in a directory");
    this.registerAction("new_ext_vol", indexDirAction);

    ImageIcon importIcon = getIcon("import.png");
    importAction = new AbstractAction("Import image...", importIcon) {

        public void actionPerformed(ActionEvent e) {
            importFile();
        }
    };
    importAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_O);
    importAction.putValue(AbstractAction.ACCELERATOR_KEY,
            KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));

    importAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Import new image into database");

    ImageIcon updateIcon = getIcon("update_indexed_dirs.png");
    UpdateIndexAction updateIndexAction = new UpdateIndexAction(viewCtrl, "Update indexed dirs", updateIcon,
            "Check for changes in previously indexed directories", KeyEvent.VK_U);
    this.registerAction("update_indexed_dirs", updateIndexAction);
    updateIndexAction.addStatusChangeListener(statusBar);

    ImageIcon previewTopIcon = getIcon("view_preview_top.png");
    DefaultAction previewTopAction = new DefaultAction("Preview on top", previewTopIcon) {

        public void actionPerformed(ActionEvent e) {
            viewCtrl.setLayout(PhotoViewController.Layout.PREVIEW_HORIZONTAL_THUMBS);
        }
    };
    previewTopAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show preview on top of thumbnails");
    previewTopAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_T);
    this.registerAction("view_preview_top", previewTopAction);

    ImageIcon previewRightIcon = getIcon("view_preview_right.png");
    DefaultAction previewRightAction = new DefaultAction("Preview on right", previewRightIcon) {

        public void actionPerformed(ActionEvent e) {
            viewCtrl.setLayout(PhotoViewController.Layout.PREVIEW_VERTICAL_THUMBS);
        }
    };
    previewRightAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show preview on right of thumbnails");
    previewRightAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_R);
    this.registerAction("view_preview_right", previewRightAction);

    ImageIcon previewNoneIcon = getIcon("view_no_preview.png");
    DefaultAction previewNoneAction = new DefaultAction("No preview", previewNoneIcon) {

        public void actionPerformed(ActionEvent e) {
            viewCtrl.setLayout(PhotoViewController.Layout.ONLY_THUMBS);
        }
    };
    previewNoneAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show no preview image");
    previewNoneAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_O);
    this.registerAction("view_no_preview", previewNoneAction);

    DefaultAction previewLargeAction = new DefaultAction("Large", null) {

        public void actionPerformed(ActionEvent e) {
            viewCtrl.setPreviewSize(200);
        }
    };
    DefaultAction previewSmallAction = new DefaultAction("Small", null) {

        public void actionPerformed(ActionEvent e) {
            viewCtrl.setPreviewSize(100);
        }
    };

    JToolBar tb = createToolbar();
    cp.add(tb, BorderLayout.NORTH);

    // Create the menu bar & menus
    JMenuBar menuBar = new JMenuBar();
    window.setJMenuBar(menuBar);
    // File menu
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(fileMenu);

    JMenuItem newWindowItem = new JMenuItem("New window", KeyEvent.VK_N);
    newWindowItem.setIcon(getIcon("window_new.png"));
    newWindowItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            BrowserWindow br = new BrowserWindow(getParentController(), null);
            //          br.setVisible( true );
        }
    });
    fileMenu.add(newWindowItem);

    JMenuItem importItem = new JMenuItem(importAction);
    fileMenu.add(importItem);

    JMenuItem indexDirItem = new JMenuItem(indexDirAction);
    fileMenu.add(indexDirItem);

    fileMenu.add(new JMenuItem(viewCtrl.getActionAdapter("update_indexed_dirs")));

    ExportSelectedAction exportAction = (ExportSelectedAction) viewPane.getExportSelectedAction();
    JMenuItem exportItem = new JMenuItem(exportAction);
    exportAction.addStatusChangeListener(statusBar);
    fileMenu.add(exportItem);

    JMenu dbMenu = new JMenu("Database");
    dbMenu.setMnemonic(KeyEvent.VK_B);
    dbMenu.setIcon(getIcon("empty_icon.png"));

    ExportMetadataAction exportMetadata = new ExportMetadataAction("Export as XML...", null,
            "Export whole database as XML file", KeyEvent.VK_E);
    dbMenu.add(new JMenuItem(exportMetadata));

    ImportXMLAction importMetadata = new ImportXMLAction("Import XML data...", null,
            "Import data from other Photovault database as XML", KeyEvent.VK_I);
    importMetadata.addStatusChangeListener(statusBar);
    dbMenu.add(new JMenuItem(importMetadata));

    fileMenu.add(dbMenu);

    JMenuItem exitItem = new JMenuItem("Exit", KeyEvent.VK_X);
    exitItem.setIcon(getIcon("exit.png"));
    exitItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    fileMenu.add(exitItem);

    JMenu viewMenu = new JMenu("View");
    viewMenu.setMnemonic(KeyEvent.VK_V);
    menuBar.add(viewMenu);

    JMenuItem vertIconsItem = new JMenuItem(previewRightAction);
    viewMenu.add(vertIconsItem);

    JMenuItem horzIconsItem = new JMenuItem(previewTopAction);
    viewMenu.add(horzIconsItem);

    JMenuItem noPreviewItem = new JMenuItem(previewNoneAction);
    viewMenu.add(noPreviewItem);

    JMenuItem nextPhotoItem = new JMenuItem(viewPane.getSelectNextAction());
    viewMenu.add(nextPhotoItem);

    JMenuItem prevPhotoItem = new JMenuItem(viewPane.getSelectPreviousAction());
    viewMenu.add(prevPhotoItem);

    viewMenu.add(new JMenuItem(previewSmallAction));
    viewMenu.add(new JMenuItem(previewLargeAction));

    JMenu sortMenu = new JMenu("Sort by");
    sortMenu.setMnemonic(KeyEvent.VK_S);
    sortMenu.setIcon(getIcon("empty_icon.png"));
    JMenuItem byDateItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new ShootingDateComparator(), "Date",
            null, "Order photos by date", KeyEvent.VK_D));
    sortMenu.add(byDateItem);
    JMenuItem byPlaceItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new ShootingPlaceComparator(),
            "Place", null, "Order photos by shooting place", KeyEvent.VK_P));
    sortMenu.add(byPlaceItem);
    JMenuItem byQualityItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new QualityComparator(),
            "Quality", null, "Order photos by quality", KeyEvent.VK_Q));
    sortMenu.add(byQualityItem);
    viewMenu.add(sortMenu);

    // Set default ordering by date
    byDateItem.getAction().actionPerformed(new ActionEvent(this, 0, "Setting default"));
    JMenu imageMenu = new JMenu("Image");
    imageMenu.setMnemonic(KeyEvent.VK_I);
    menuBar.add(imageMenu);

    imageMenu.add(new JMenuItem(viewPane.getEditSelectionPropsAction()));
    imageMenu.add(new JMenuItem(viewPane.getShowSelectedPhotoAction()));
    imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_cw")));
    imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_ccw")));
    imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_180")));
    imageMenu.add(new JMenuItem(previewPane.getCropAction()));
    imageMenu.add(new JMenuItem(viewPane.getEditSelectionColorsAction()));
    imageMenu.add(new JMenuItem(viewPane.getDeleteSelectedAction()));

    // Create the Quality submenu
    JMenu qualityMenu = new JMenu("Quality");
    qualityMenu.setIcon(getIcon("empty_icon.png"));

    for (int n = 0; n < 6; n++) {
        Action qualityAction = viewCtrl.getActionAdapter("quality_" + n);
        JMenuItem qualityMenuItem = new JMenuItem(qualityAction);
        qualityMenu.add(qualityMenuItem);
    }
    imageMenu.add(qualityMenu);

    JMenu aboutMenu = new JMenu("About");
    aboutMenu.setMnemonic(KeyEvent.VK_A);
    aboutMenu.add(new JMenuItem(new ShowAboutDlgAction("About Photovault...", null, "", null)));

    menuBar.add(Box.createHorizontalGlue());
    menuBar.add(aboutMenu);
    window.pack();
    window.setVisible(true);
}

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

public MainFrame(String version) {

    super("Galleon " + version);

    setDefaultCloseOperation(0);//  w  w w  . 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:edu.purdue.cc.bionet.ui.CorrelationDisplayPanel.java

/**
 * Adds all of the necessary Components to this Component.
 *//*from w  ww  .  j  a  va2 s.co  m*/
private void buildPanel() {

    Language language = Settings.getLanguage();
    this.correlationMethodMenu = new JMenu(language.get("Correlation Method"));
    this.correlationMethodMenuButtonGroup = new ButtonGroup();
    this.pearsonCalculationMenuItem = new JRadioButtonMenuItem(language.get("Pearson"), true);
    this.spearmanCalculationMenuItem = new JRadioButtonMenuItem(language.get("Spearman"));
    this.kendallCalculationMenuItem = new JRadioButtonMenuItem(language.get("Kendall"));

    // layout menu itmes
    this.layoutMenu = new JMenu(language.get("Layout"));
    this.layoutMenuButtonGroup = new ButtonGroup();
    this.multipleCirclesLayoutMenuItem = new JRadioButtonMenuItem(language.get("Multiple Circles"));
    this.singleCircleLayoutMenuItem = new JRadioButtonMenuItem(language.get("Single Circle"), true);
    this.randomLayoutMenuItem = new JRadioButtonMenuItem(language.get("Random"));
    this.heatMapLayoutMenuItem = new JRadioButtonMenuItem(language.get("Heat Map"));
    this.kkLayoutMenuItem = new JRadioButtonMenuItem(language.get("Kamada-Kawai"));
    //      this.frLayoutMenuItem = 
    //            new JRadioButtonMenuItem( language.get( "Fruchterman-Reingold" ));
    //      this.springLayoutMenuItem = 
    //               new JRadioButtonMenuItem( language.get( "Spring Layout" ));
    this.frSpringLayoutMenuItem = new JRadioButtonMenuItem(language.get("Spring Layout"));
    //      this.animatedLayoutMenuItem = new JCheckBoxMenuItem( 
    //         language.get( "Fruchterman-Reingold Spring Embedding" ));

    // view menu items
    this.viewMenu = new JMenu(language.get("View"));
    this.zoomInViewMenuItem = new JMenuItem(language.get("Zoom In"), KeyEvent.VK_I);
    this.zoomOutViewMenuItem = new JMenuItem(language.get("Zoom Out"), KeyEvent.VK_O);
    this.fitToWindowViewMenuItem = new JMenuItem(language.get("Fit to Window"), KeyEvent.VK_F);
    this.selectAllViewMenuItem = new JMenuItem(language.get("Select All"), KeyEvent.VK_A);
    this.clearSelectionViewMenuItem = new JMenuItem(language.get("Clear Selection"), KeyEvent.VK_C);
    this.invertSelectionViewMenuItem = new JMenuItem(language.get("Invert Selection"), KeyEvent.VK_I);
    this.selectCorrelatedViewMenuItem = new JMenuItem(language.get("Select Correlated to Selection"),
            KeyEvent.VK_R);
    this.hideSelectedViewMenuItem = new JMenuItem(language.get("Hide Selected"), KeyEvent.VK_H);
    this.hideUnselectedViewMenuItem = new JMenuItem(language.get("Hide Unselected"), KeyEvent.VK_U);
    this.hideUncorrelatedViewMenuItem = new JMenuItem(language.get("Hide Uncorrelated to Selection"),
            KeyEvent.VK_L);
    this.hideOrphansViewMenuItem = new JMenuItem(language.get("Hide Orphans"), KeyEvent.VK_P);
    this.showCorrelatedViewMenuItem = new JMenuItem(language.get("Show All Correlated to Visible"),
            KeyEvent.VK_S);
    this.saveImageAction = new SaveImageAction(language.get("Save Main Graph Image") + "...", null);

    // groups menu items
    this.groupsMenu = new JMenu(language.get("Groups"));
    this.resetSampleGroupsMenuItem = new JMenuItem(language.get("Reset Sample Groups"), KeyEvent.VK_R);
    this.chooseSampleGroupsMenuItem = new JMenuItem(language.get("Choose Sample Groups") + "...",
            KeyEvent.VK_C);

    // color menu items
    this.colorMenu = new JMenu(language.get("Color"));
    this.colorMenuButtonGroup = new ButtonGroup();
    this.normalColorMenuItem = new JRadioButtonMenuItem(language.get("Normal Color"), true);
    this.highContrastColorMenuItem = new JRadioButtonMenuItem(language.get("High Contrast Color"));

    // CORRELATION FILTER ELEMENTS
    JPanel leftPanel = new JPanel(new BorderLayout());
    this.moleculeFilterPanel = new MoleculeFilterPanel();
    leftPanel.add(moleculeFilterPanel, BorderLayout.CENTER);
    this.correlationFilterPanel = new CorrelationFilterPanel();
    leftPanel.add(this.correlationFilterPanel, BorderLayout.SOUTH);

    //CALCULATION MENU
    this.correlationMethodMenu.setMnemonic(KeyEvent.VK_C);
    this.correlationMethodMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Perform Data Calculations"));
    this.correlationMethodMenuButtonGroup.add(this.pearsonCalculationMenuItem);
    this.correlationMethodMenuButtonGroup.add(this.spearmanCalculationMenuItem);
    this.correlationMethodMenuButtonGroup.add(this.kendallCalculationMenuItem);
    this.pearsonCalculationMenuItem.setMnemonic(KeyEvent.VK_P);
    this.spearmanCalculationMenuItem.setMnemonic(KeyEvent.VK_S);
    this.kendallCalculationMenuItem.setMnemonic(KeyEvent.VK_K);
    this.correlationMethodMenu.add(this.pearsonCalculationMenuItem);
    this.correlationMethodMenu.add(this.spearmanCalculationMenuItem);
    this.correlationMethodMenu.add(this.kendallCalculationMenuItem);
    this.pearsonCalculationMenuItem.addItemListener(this);
    this.spearmanCalculationMenuItem.addItemListener(this);
    this.kendallCalculationMenuItem.addItemListener(this);

    //LAYOUT MENU
    LayoutChangeListener lcl = new LayoutChangeListener();
    this.layoutMenu.setMnemonic(KeyEvent.VK_L);
    this.layoutMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Change the layout of the graph"));
    this.layoutMenuButtonGroup.add(this.multipleCirclesLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.singleCircleLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.randomLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.kkLayoutMenuItem);
    //      this.layoutMenuButtonGroup.add( this.frLayoutMenuItem );
    //      this.layoutMenuButtonGroup.add( this.springLayoutMenuItem );
    this.layoutMenuButtonGroup.add(this.frSpringLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.heatMapLayoutMenuItem);

    Enumeration<AbstractButton> e = this.layoutMenuButtonGroup.getElements();
    this.layoutMenu.add(this.multipleCirclesLayoutMenuItem);
    this.layoutMenu.add(this.singleCircleLayoutMenuItem);
    this.layoutMenu.add(this.randomLayoutMenuItem);
    this.layoutMenu.add(this.kkLayoutMenuItem);
    //      this.layoutMenu.add( this.frLayoutMenuItem );
    //      this.layoutMenu.add( this.springLayoutMenuItem );
    this.layoutMenu.add(this.frSpringLayoutMenuItem);
    this.layoutMenu.add(this.heatMapLayoutMenuItem);
    //      this.layoutMenu.addSeparator( );
    //      this.layoutMenu.add( this.animatedLayoutMenuItem );
    this.multipleCirclesLayoutMenuItem.addActionListener(lcl);
    this.multipleCirclesLayoutMenuItem.setEnabled(false);
    this.singleCircleLayoutMenuItem.addActionListener(lcl);
    this.randomLayoutMenuItem.addActionListener(lcl);
    this.kkLayoutMenuItem.addActionListener(lcl);
    //      this.frLayoutMenuItem.addActionListener( lcl );
    this.frSpringLayoutMenuItem.addActionListener(lcl);
    this.heatMapLayoutMenuItem.addActionListener(lcl);
    //      this.animatedLayoutMenuItem.addActionListener( lcl );

    //VIEW MENU
    this.viewMenu.add(this.colorMenu);
    this.viewMenu.addSeparator();
    this.viewMenu.setMnemonic(KeyEvent.VK_V);
    this.viewMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Change the data view settings"));
    this.viewMenu.add(this.zoomOutViewMenuItem);
    this.viewMenu.add(this.zoomInViewMenuItem);
    this.viewMenu.add(this.fitToWindowViewMenuItem);
    this.viewMenu.addSeparator();
    this.viewMenu.add(this.selectAllViewMenuItem);
    this.viewMenu.add(this.clearSelectionViewMenuItem);
    this.viewMenu.add(this.invertSelectionViewMenuItem);
    this.viewMenu.add(this.selectCorrelatedViewMenuItem);
    this.viewMenu.addSeparator();
    this.viewMenu.add(this.hideSelectedViewMenuItem);
    this.viewMenu.add(this.hideUnselectedViewMenuItem);
    this.viewMenu.add(this.hideUncorrelatedViewMenuItem);
    this.viewMenu.add(this.hideOrphansViewMenuItem);
    this.viewMenu.add(this.showCorrelatedViewMenuItem);
    this.viewMenu.addSeparator();
    this.viewMenu.add(this.saveImageAction);
    this.resetSampleGroupsMenuItem.addActionListener(this);
    this.chooseSampleGroupsMenuItem.addActionListener(this);
    this.zoomOutViewMenuItem.addActionListener(this);
    this.zoomInViewMenuItem.addActionListener(this);
    this.fitToWindowViewMenuItem.addActionListener(this);
    this.selectAllViewMenuItem.addActionListener(this);
    this.clearSelectionViewMenuItem.addActionListener(this);
    this.invertSelectionViewMenuItem.addActionListener(this);
    this.selectCorrelatedViewMenuItem.addActionListener(this);
    this.hideSelectedViewMenuItem.addActionListener(this);
    this.hideUnselectedViewMenuItem.addActionListener(this);
    this.hideUncorrelatedViewMenuItem.addActionListener(this);
    this.hideOrphansViewMenuItem.addActionListener(this);
    this.showCorrelatedViewMenuItem.addActionListener(this);
    this.selectAllViewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK));
    this.clearSelectionViewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));

    // GROUPS MENU
    this.groupsMenu.setMnemonic(KeyEvent.VK_G);
    this.groupsMenu.add(this.resetSampleGroupsMenuItem);
    this.groupsMenu.add(this.chooseSampleGroupsMenuItem);

    this.zoomOutViewMenuItem
            .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK));
    this.zoomInViewMenuItem
            .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.CTRL_DOWN_MASK));
    this.fitToWindowViewMenuItem
            .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_0, InputEvent.CTRL_DOWN_MASK));
    this.hideSelectedViewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));

    //COLOR MENU
    this.colorMenu.setMnemonic(KeyEvent.VK_R);
    this.colorMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Change the color of the graph"));
    this.colorMenuButtonGroup.add(this.normalColorMenuItem);
    this.colorMenuButtonGroup.add(this.highContrastColorMenuItem);
    this.colorMenu.add(this.normalColorMenuItem);
    this.colorMenu.add(this.highContrastColorMenuItem);
    this.normalColorMenuItem.addItemListener(this);
    this.highContrastColorMenuItem.addItemListener(this);

    this.menuBar.add(this.correlationMethodMenu);
    this.menuBar.add(this.layoutMenu);
    this.menuBar.add(this.viewMenu);
    this.menuBar.add(this.groupsMenu);

    // Add the panels to the main panel
    this.add(menuBar, BorderLayout.NORTH);
    //      this.add( this.correlationViewPanel, BorderLayout.CENTER );
    this.add(leftPanel, BorderLayout.WEST);
}