Example usage for java.awt.event KeyEvent VK_E

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

Introduction

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

Prototype

int VK_E

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

Click Source Link

Document

Constant for the "E" key.

Usage

From source file:org.f2o.absurdum.puck.gui.PuckFrame.java

/**
 * Instances and shows Puck's main frame.
 *//*from  ww w.  j  a  v  a2 s .c o m*/
public PuckFrame() {

    super();

    setLookAndFeel(PuckConfiguration.getInstance().getProperty("look"));

    /*
    LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels();
    for ( int i = 0 ; i < lfs.length ; i++ )
    {
       if ( lfs[i].getName().toLowerCase().contains("nimbus") )
       {
    try 
    {
       UIManager.setLookAndFeel(lfs[i].getClassName());
    } 
    catch (Exception e) //class not found, instantiation exception, etc. (shouldn't happen)
    {
       e.printStackTrace();
    }
            
       }
    }
    */

    setSize(PuckConfiguration.getInstance().getIntegerProperty("windowWidth"),
            PuckConfiguration.getInstance().getIntegerProperty("windowHeight"));
    setLocation(PuckConfiguration.getInstance().getIntegerProperty("windowLocationX"),
            PuckConfiguration.getInstance().getIntegerProperty("windowLocationY"));
    //setSize(600,600);
    if (PuckConfiguration.getInstance().getBooleanProperty("windowMaximized"))
        maximizeIfPossible();
    //setTitle(Messages.getInstance().getMessage("frame.title"));
    refreshTitle();
    left = new JPanel();
    right = new JPanel();
    JScrollPane rightScroll = new JScrollPane(right);
    rightScroll.getVerticalScrollBar().setUnitIncrement(16); //faster scrollbar (by default it was very slow, maybe because component inside is not text component!)
    split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, rightScroll) {
        //dynamic resizing of right panel
        /*
        public void setDividerLocation ( int pixels )
        {
              if ( propPanel != null )
              {
          double rightPartSize = getContentPane().getWidth() - pixels - 15;
          System.out.println("rps=" + rightPartSize);
          System.out.println("mnw=" + this.getMinimumSize().getWidth());
          Dimension propPanSize = propPanel.getSize();
          int propPanHeight = 0;
          if (propPanSize != null) propPanHeight = (int) propPanSize.getHeight();
          //propPanel.revalidate();
          System.out.println("h " + propPanHeight);
          //if ( rightPartSize >= propPanel.getMinimumSize().getWidth() )
             propPanel.setPreferredSize(new Dimension((int)rightPartSize,propPanHeight));
             //propPanel.setMinimumSize(new Dimension((int)rightPartSize,propPanHeight));
             //propPanel.setMaximumSize(new Dimension((int)rightPartSize,propPanHeight));
             //propPanel.setSize(new Dimension((int)rightPartSize,propPanHeight));
             propPanel.revalidate();
              }
              super.setDividerLocation(pixels);
        }
        */

    };
    split.setContinuousLayout(true);
    split.setResizeWeight(0.60);
    final int dividerLoc = PuckConfiguration.getInstance().getIntegerProperty("dividerLocation", 0);

    /*
    SwingUtilities.invokeLater(new Runnable(){
    public void run()
    {
    */

    /*   
    }
    });
    */
    split.setOneTouchExpandable(true);
    getContentPane().add(split);

    System.out.println(Toolkit.getDefaultToolkit().getBestCursorSize(20, 20));
    //it's 32x32. Will have to do it.

    //Image img = Toolkit.getDefaultToolkit().createImage( getClass().getResource("addCursor32.png") );

    //Image img = Toolkit.getDefaultToolkit().createImage("addCursor32.png");

    left.setLayout(new BorderLayout());

    //right.setLayout(new BoxLayout(right,BoxLayout.LINE_AXIS));
    if (PuckConfiguration.getInstance().getBooleanProperty("dynamicFormResizing"))
        right.setLayout(new BorderLayout());
    else
        right.setLayout(new FlowLayout());

    propPanel = new PropertiesPanel();
    right.add(propPanel);

    graphPanel = new GraphEditingPanel(propPanel);
    graphPanel.setGrid(Boolean.valueOf(PuckConfiguration.getInstance().getProperty("showGrid")).booleanValue());
    graphPanel.setSnapToGrid(
            Boolean.valueOf(PuckConfiguration.getInstance().getProperty("snapToGrid")).booleanValue());
    propPanel.setGraphEditingPanel(graphPanel);
    tools = new PuckToolBar(graphPanel, propPanel, this);
    left.add(tools, BorderLayout.WEST);
    left.add(graphPanel, BorderLayout.CENTER);

    /*
    Action testAction = 
    new AbstractAction()
    {
       public void actionPerformed ( ActionEvent evt )
       {
          System.out.println("Puck!");
       }
    }
    ;
    testAction.putValue(Action.NAME,"Print Puck");
            
    tools.add(testAction);
    */

    /*
    public void saveChanges ( )
    {
       if ( editingFileName == null )
       {
    //save as... code
       }
       else
       {
    File f = new File(editingFileName);
    try
    {
       Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
       d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d));
       Transformer t = TransformerFactory.newInstance().newTransformer();
       Source s = new DOMSource(d);
       Result r = new StreamResult(f);
       t.transform(s,r);
       editingFileName = f.toString();
       refreshTitle();
    }
    catch ( Exception e )
    {
       JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE);
       e.printStackTrace();
    }
       }
    }
    */

    JMenuBar mainMenuBar = new JMenuBar();
    JMenu fileMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file"));
    fileMenu.setMnemonic(KeyEvent.VK_F);
    saveMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.save"));
    saveMenuItem.setMnemonic(KeyEvent.VK_S);
    saveMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (editingFileName == null)
                JOptionPane.showMessageDialog(PuckFrame.this, "File has no name!", "Whoops!",
                        JOptionPane.ERROR_MESSAGE);
            /*
            File f = new File(editingFileName);
            try
            {
             Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
             d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d));
             Transformer t = TransformerFactory.newInstance().newTransformer();
             Source s = new DOMSource(d);
             Result r = new StreamResult(f);
             t.transform(s,r);
             editingFileName = f.toString();
             refreshTitle();
            }
            catch ( Exception e )
            {
             JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE);
             e.printStackTrace();
            }
            */
            try {
                saveChangesInCurrentFile();
            } catch (Exception e) {
                JOptionPane.showMessageDialog(PuckFrame.this, e.getLocalizedMessage(), "Whoops!",
                        JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
            }
        }
    });
    JMenu newMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.new"));
    JMenuItem newBlankMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.new.blank"));
    //newBlankMenuItem.setMnemonic(KeyEvent.VK_N);
    newBlankMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            GraphElementPanel.emptyQueue(); //stop deferred loads
            graphPanel.clear();
            propPanel.clear();
            JSyntaxBSHCodeFrame.closeAllInstances();
            WorldPanel wp = new WorldPanel(graphPanel);
            WorldNode wn = new WorldNode(wp);
            graphPanel.setWorldNode(wn);
            propPanel.show(graphPanel.getWorldNode());
            resetCurrentlyEditingFile();
            refreshTitle();
            //revalidate(); //only since java 1.7
            //invalidate();
            //validate();
            split.revalidate(); //JComponents do have it before java 1.7 (not JFrame)
        }
    });
    newMenu.add(newBlankMenuItem);
    JMenu templateMenus = new WorldTemplateMenuBuilder(this).getMenu();
    if (templateMenus != null) {
        for (int i = 0; i < templateMenus.getItemCount(); i++) {
            if (i == 0)
                newMenu.add(new JSeparator());
            newMenu.add(templateMenus.getItem(i));
        }
    }
    JMenuItem saveAsMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.saveas"));
    saveAsMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            /*
            JFileChooser jfc = new JFileChooser(".");
            int opt = jfc.showSaveDialog(PuckFrame.this);
            if ( opt == JFileChooser.APPROVE_OPTION )
            {
             File f = jfc.getSelectedFile();
             try
             {
                Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
                d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d));
                Transformer t = TransformerFactory.newInstance().newTransformer();
                Source s = new DOMSource(d);
                Result r = new StreamResult(f);
                t.transform(s,r);
                editingFileName = f.toString();
                saveMenuItem.setEnabled(true);
                refreshTitle();
             }
             catch ( Exception e )
             {
                JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
             }
            }
            */
            try {
                saveAs();
                saveMenuItem.setEnabled(true);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(PuckFrame.this, e.getLocalizedMessage(), "Whoops!",
                        JOptionPane.ERROR_MESSAGE);
                e.printStackTrace();
            }
            //saveAs(saveMenuItem);
        }
    });
    JMenuItem openMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.open"));
    openMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            //graphPanel.setVisible(false);
            //propPanel.setVisible(false);

            JFileChooser jfc = new JFileChooser(".");
            jfc.setFileFilter(new FiltroFicheroMundo());
            int opt = jfc.showOpenDialog(PuckFrame.this);
            if (opt == JFileChooser.APPROVE_OPTION) {
                File f = jfc.getSelectedFile();
                openFileOrShowError(f);
            }

            //graphPanel.setVisible(true);
            //propPanel.setVisible(true);
        }
    });
    openRecentMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.recent"));
    JMenuItem exitMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.exit"));
    exitMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {

            /*
            int opt = JOptionPane.showConfirmDialog(PuckFrame.this,Messages.getInstance().getMessage("exit.sure.text"),Messages.getInstance().getMessage("exit.sure.title"),JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
                    
            if ( opt == JOptionPane.YES_OPTION )
             System.exit(0);
            */
            userExit();

        }
    });
    JMenu exportMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.export"));
    JMenuItem exportAppletMenuItem = new JMenuItem(
            UIMessages.getInstance().getMessage("menu.file.export.applet"));
    exportAppletMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            ExportAppletDialog dial = new ExportAppletDialog(PuckFrame.this);
            dial.setVisible(true);
        }
    });
    exportMenu.add(exportAppletMenuItem);

    fileMenu.add(newMenu);
    fileMenu.add(openMenuItem);
    fileMenu.add(openRecentMenu);
    updateRecentMenu();
    fileMenu.add(new JSeparator());
    saveMenuItem.setEnabled(false);
    fileMenu.add(saveMenuItem);
    fileMenu.add(saveAsMenuItem);
    fileMenu.add(exportMenu);
    fileMenu.add(new JSeparator());
    fileMenu.add(exitMenuItem);

    mainMenuBar.add(fileMenu);

    /**
     * Create an Edit menu to support cut/copy/paste.
     */

    JMenu editMenu = new JMenu(UIMessages.getInstance().getMessage("menu.edit"));
    editMenu.setMnemonic(KeyEvent.VK_E);

    JMenuItem findMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.find.entity"));
    findMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showFindEntityDialog();
        }
    });
    editMenu.add(findMenuItem);
    editMenu.add(new JSeparator());

    JMenuItem aMenuItem = new JMenuItem(new CutAction());
    aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.cut"));
    aMenuItem.setMnemonic(KeyEvent.VK_T);
    editMenu.add(aMenuItem);

    aMenuItem = new JMenuItem(new CopyAction());
    aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.copy"));
    aMenuItem.setMnemonic(KeyEvent.VK_C);
    editMenu.add(aMenuItem);

    aMenuItem = new JMenuItem(new PasteAction());
    aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.paste"));
    aMenuItem.setMnemonic(KeyEvent.VK_P);
    editMenu.add(aMenuItem);

    mainMenuBar.add(editMenu);

    JMenu optionsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options"));
    JMenu gridMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options.grid"));
    optionsMenu.add(gridMenu);
    final JCheckBoxMenuItem showGridItem = new JCheckBoxMenuItem(
            UIMessages.getInstance().getMessage("menu.options.grid.show"));
    showGridItem.setSelected(
            Boolean.valueOf(PuckConfiguration.getInstance().getProperty("showGrid")).booleanValue());
    gridMenu.add(showGridItem);
    showGridItem.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                graphPanel.setGrid(true);
                PuckConfiguration.getInstance().setProperty("showGrid", "true");
            } else if (e.getStateChange() == ItemEvent.DESELECTED) {
                graphPanel.setGrid(false);
                PuckConfiguration.getInstance().setProperty("showGrid", "false");
            }
            graphPanel.repaint();
        }
    });
    final JCheckBoxMenuItem snapToGridItem = new JCheckBoxMenuItem(
            UIMessages.getInstance().getMessage("menu.options.grid.snap"));
    snapToGridItem.setSelected(
            Boolean.valueOf(PuckConfiguration.getInstance().getProperty("snapToGrid")).booleanValue());
    gridMenu.add(snapToGridItem);
    snapToGridItem.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                graphPanel.setSnapToGrid(true);
                PuckConfiguration.getInstance().setProperty("snapToGrid", "true");
            } else if (e.getStateChange() == ItemEvent.DESELECTED) {
                graphPanel.setSnapToGrid(false);
                PuckConfiguration.getInstance().setProperty("snapToGrid", "false");
            }
            graphPanel.repaint();
        }
    });

    JMenuItem translationModeMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options.translation"));
    ButtonGroup translationGroup = new ButtonGroup();
    final JRadioButtonMenuItem holdMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.options.translation.hold"));
    final JRadioButtonMenuItem pushMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.options.translation.push"));
    pushMenuItem.setSelected("push".equals(PuckConfiguration.getInstance().getProperty("translateMode")));
    if (!pushMenuItem.isSelected())
        holdMenuItem.setSelected(true);
    translationGroup.add(holdMenuItem);
    translationGroup.add(pushMenuItem);
    holdMenuItem.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent arg0) {
            if (holdMenuItem.isSelected())
                PuckConfiguration.getInstance().setProperty("translateMode", "hold");
            else
                PuckConfiguration.getInstance().setProperty("translateMode", "push");
        }
    });
    translationModeMenu.add(holdMenuItem);
    translationModeMenu.add(pushMenuItem);
    optionsMenu.add(translationModeMenu);

    JMenuItem toolSelectionModeMenu = new JMenu(
            UIMessages.getInstance().getMessage("menu.options.toolselection"));
    ButtonGroup toolSelectionGroup = new ButtonGroup();
    final JRadioButtonMenuItem oneUseMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.options.toolselection.oneuse"));
    final JRadioButtonMenuItem multipleUseMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.options.toolselection.multipleuse"));
    multipleUseMenuItem.setSelected(
            "multipleUse".equalsIgnoreCase(PuckConfiguration.getInstance().getProperty("toolSelectionMode")));
    if (!multipleUseMenuItem.isSelected())
        oneUseMenuItem.setSelected(true);
    toolSelectionGroup.add(oneUseMenuItem);
    toolSelectionGroup.add(multipleUseMenuItem);
    oneUseMenuItem.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent arg0) {
            if (oneUseMenuItem.isSelected())
                PuckConfiguration.getInstance().setProperty("toolSelectionMode", "oneUse");
            else
                PuckConfiguration.getInstance().setProperty("toolSelectionMode", "multipleUse");
        }
    });
    toolSelectionModeMenu.add(oneUseMenuItem);
    toolSelectionModeMenu.add(multipleUseMenuItem);
    optionsMenu.add(toolSelectionModeMenu);

    JMenuItem sizesMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.iconsizes"));
    sizesMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            IconSizesDialog dial = new IconSizesDialog(PuckFrame.this, true);
            dial.setVisible(true);
        }
    });
    optionsMenu.add(sizesMenuItem);

    JMenuItem showHideMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.showhide"));
    showHideMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ShowHideDialog dial = new ShowHideDialog(PuckFrame.this, true);
            dial.setVisible(true);
        }
    });
    optionsMenu.add(showHideMenuItem);

    JMenuItem mapColorsMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.mapcolors"));
    mapColorsMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            MapColorsDialog dial = new MapColorsDialog(PuckFrame.this, true);
            dial.setVisible(true);
        }
    });
    optionsMenu.add(mapColorsMenuItem);

    String skinList = PuckConfiguration.getInstance().getProperty("availableSkins");
    if (skinList != null && skinList.trim().length() > 0) {
        JMenu skinsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.skins"));
        StringTokenizer st = new StringTokenizer(skinList, ", ");
        ButtonGroup skinButtons = new ButtonGroup();
        while (st.hasMoreTokens()) {
            final String nextSkin = st.nextToken();
            final JRadioButtonMenuItem skinMenuItem = new JRadioButtonMenuItem(nextSkin);
            skinMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    setSkin(nextSkin);
                    skinMenuItem.setSelected(true);
                }
            });
            if (nextSkin.equals(PuckConfiguration.getInstance().getProperty("skin")))
                skinMenuItem.setSelected(true);
            skinsMenu.add(skinMenuItem);
            skinButtons.add(skinMenuItem);
        }
        optionsMenu.add(skinsMenu);
    }

    JMenu lookFeelMenu = new JMenu(UIMessages.getInstance().getMessage("menu.looks"));
    ButtonGroup lookButtons = new ButtonGroup();
    final JRadioButtonMenuItem defaultLookMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.looks.default"));
    if ("default".equals(PuckConfiguration.getInstance().getProperty("look"))) {
        defaultLookMenuItem.setSelected(true);
    }
    lookFeelMenu.add(defaultLookMenuItem);
    lookButtons.add(defaultLookMenuItem);
    defaultLookMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setLookAndFeel("default");
            defaultLookMenuItem.setSelected(true);
        }
    });
    final JRadioButtonMenuItem systemLookMenuItem = new JRadioButtonMenuItem(
            UIMessages.getInstance().getMessage("menu.looks.system"));
    if ("system".equals(PuckConfiguration.getInstance().getProperty("look"))) {
        systemLookMenuItem.setSelected(true);
    }
    lookFeelMenu.add(systemLookMenuItem);
    lookButtons.add(systemLookMenuItem);
    systemLookMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setLookAndFeel("system");
            systemLookMenuItem.setSelected(true);
        }
    });
    String additionalLookList = PuckConfiguration.getInstance().getProperty("additionalLooks");
    if (additionalLookList != null && additionalLookList.trim().length() > 0) {
        StringTokenizer st = new StringTokenizer(additionalLookList, ", ");
        while (st.hasMoreTokens()) {
            final String nextLook = st.nextToken();
            final JRadioButtonMenuItem lookMenuItem = new JRadioButtonMenuItem(nextLook);
            lookMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    setLookAndFeel(nextLook);
                    lookMenuItem.setSelected(true);
                }
            });
            if (nextLook.equals(PuckConfiguration.getInstance().getProperty("look"))) {
                lookMenuItem.setSelected(true);
            }
            lookFeelMenu.add(lookMenuItem);
            lookButtons.add(lookMenuItem);
        }
    }
    optionsMenu.add(lookFeelMenu);

    optionsMenu.add(new UILanguageSelectionMenu(this));

    mainMenuBar.add(optionsMenu);

    JMenu toolsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.tools"));

    final JMenuItem verbListMenuItem = new JMenuItem(
            UIMessages.getInstance().getMessage("menu.tools.verblist"));
    verbListMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            WorldPanel wp = (WorldPanel) graphPanel.getWorldNode().getAssociatedPanel();
            VerbListFrame vlf = VerbListFrame.getInstance(wp.getSelectedLanguageCode());
            vlf.setVisible(true);
        }
    });
    toolsMenu.add(verbListMenuItem);

    final JMenuItem validateMenuItem = new JMenuItem(
            UIMessages.getInstance().getMessage("menu.tools.validatebsh"));
    validateMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            BeanShellCodeValidator bscv = new BeanShellCodeValidator(graphPanel);
            if (!bscv.validate()) {
                BeanShellErrorsDialog bsed = new BeanShellErrorsDialog(PuckFrame.this, bscv.getErrorText());
                bsed.setVisible(true);
                //JOptionPane.showMessageDialog(PuckFrame.this, bscv.getErrorText());
            } else {
                JOptionPane.showMessageDialog(PuckFrame.this,
                        UIMessages.getInstance().getMessage("bsh.code.ok"), "OK!",
                        JOptionPane.INFORMATION_MESSAGE);
                //JOptionPane.showMessageDialog(PuckFrame.this, bscv.getErrorText());
            }
        }
    });
    toolsMenu.add(validateMenuItem);

    mainMenuBar.add(toolsMenu);

    JMenu helpMenu = new JMenu(UIMessages.getInstance().getMessage("menu.help"));
    //JHelpAction.startHelpWorker("help/PUCKHelp.hs");
    //JHelpAction helpTocAction = JHelpAction.getShowHelpInstance(Messages.getInstance().getMessage("menu.help.toc"));
    //JHelpAction helpContextSensitiveAction = JHelpAction.getTrackInstance(Messages.getInstance().getMessage("menu.help.context"));
    //final JMenuItem helpTocMenuItem = new JMenuItem(helpTocAction);
    //final JMenuItem helpContextSensitiveMenuItem = new JMenuItem(helpContextSensitiveAction);
    //helpMenu.add(helpTocMenuItem);
    //helpMenu.add(helpContextSensitiveMenuItem);

    final JMenuItem helpMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.help.toc"));
    helpMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DocumentationLinkDialog dial = new DocumentationLinkDialog(PuckFrame.this, true);
            dial.setVisible(true);
        }
    });
    helpMenu.add(helpMenuItem);

    mainMenuBar.add(helpMenu);

    MenuMnemonicOnTheFly.setMnemonics(mainMenuBar);

    this.setJMenuBar(mainMenuBar);

    //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            userExit();
        }
    });

    propPanel.show(graphPanel.getWorldNode());

    setVisible(true);

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            if (dividerLoc > 0)
                split.setDividerLocation(dividerLoc);
            else
                split.setDividerLocation(0.60);
        }
    });

}

From source file:edu.harvard.mcz.imagecapture.PositionTemplateEditor.java

/**
 * This method initializes jMenuItem2   
 *    /*from  w  w  w .j a v  a 2 s. com*/
 * @return javax.swing.JMenuItem   
 */
private JMenuItem getJMenuItem2() {
    if (jMenuItem2 == null) {
        jMenuItem2 = new JMenuItem();
        if (runningFromMain) {
            jMenuItem2.setText("Exit");
            jMenuItem2.setMnemonic(KeyEvent.VK_E);
        } else {
            jMenuItem2.setText("Close Window");
            jMenuItem2.setMnemonic(KeyEvent.VK_C);
        }
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                if (runningFromMain) {
                    ImageCaptureApp.exit(ImageCaptureApp.EXIT_NORMAL);
                } else {
                    thisFrame.setVisible(false);
                }
            }
        });
    }
    return jMenuItem2;
}

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

/**
 * Build main menu./*from   w w w. j a  v  a 2s. c  o  m*/
 * 
 * @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:com.jcraft.weirdx.DDXWindowImp.java

public void keyPressed(KeyEvent e) {
    if (!window.isMapped())
        return;//  w w  w .jav  a2s . c  o m

    if (e.getKeyCode() == KeyEvent.VK_CAPS_LOCK) {
        if (clck_toggle) {
            clck_toggle = false;
            XWindow.sprite.hot.state &= (~1);
        } else {
            clck_toggle = true;
            XWindow.sprite.hot.state |= 1;
        }
    }

    // Easter Egg...
    if (window == window.screen.root && 0 < px && px < 3 && 0 < py && py < 3) {
        if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_W) {
            LogoImage.toggle();
        } else if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_E) {
            XWindow.printWindowTree(window.screen.root);
        }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_I){
        //   if(WeirdX.acontext!=null){
        //     acontext.showDocument(new URL("http://www.weirdx.org/"), "_blank");
        //   }
        //    }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_R){
        //   }
        //    }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_D){
        //   }
        //    }
        //    else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) &&
        //         e.getKeyCode()==KeyEvent.VK_X){
        //   }
        //    }
    }

    XWindow dest = XWindow.sprite.win;
    if (XWindow.focus.window != null)
        dest = XWindow.focus.window;

    if (window.screen.windowmode != 0 && dest == window.screen.root) {
        if (XWindow.focus.window != null)
            dest = XWindow.sprite.win;
        else
            dest = window;
    }

    if (dest.client == null)
        return;

    int kcode = Keymap.km.getCode(e);
    event.mkKeyPress(kcode, window.screen.rootId, dest.id, 0, XWindow.sprite.hot.x, XWindow.sprite.hot.y,
            XWindow.sprite.hot.x - window.x, XWindow.sprite.hot.y - window.y, XWindow.sprite.hot.state, 1);

    try {
        if (XWindow.grab != null)
            XWindow.sendGrabbedEvent(event, false, 1);
        else
            XWindow.sendDeviceEvent(dest, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }

    kcode = e.getKeyCode();
    int state = XWindow.sprite.hot.state;
    if (kcode == KeyEvent.VK_CONTROL) {
        if ((state & 4) == 0)
            state |= 4;
    } else if (kcode == KeyEvent.VK_SHIFT) {
        if ((state & 1) == 0)
            state |= 1;
    } else if (kcode == KeyEvent.VK_ALT) {
        if ((state & 8) == 0)
            state |= 8;
    } else if (kcode == VK_ALT_GRAPH) {
        if ((state & ALT_GR_MASK) == 0)
            state |= ALT_GR_MASK;
    }
    // check for windoze ALT_GR (is equal to ALT+CONTROL)
    if ((state & 12) == 12) {
        state -= 12;
        state |= ALT_GR_MASK;
    }
    XWindow.sprite.hot.state = state;
}

From source file:org.jas.gui.MainWindow.java

private JMenuItem getExitMenuItem() {
    if (exitMenuItem == null) {
        exitMenuItem = new JMenuItem(JMENU_EXIT_LABEL);
        exitMenuItem.setName(EXIT_MENU_ITEM);
        exitMenuItem.setMnemonic(KeyEvent.VK_E);

        exitMenuItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                System.exit(0);// w  w  w .  j av a  2s  .  c o m
            }
        });
    }
    return exitMenuItem;
}

From source file:oct.analysis.application.OCTAnalysisUI.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*w  ww  .j ava 2 s.  com*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

    lrpButtonGroup = new javax.swing.ButtonGroup();
    analysisToolBarBtnGroup = new javax.swing.ButtonGroup();
    toolsToolBarBtnGroup = new javax.swing.ButtonGroup();
    lrpSelectionWidthBean = new oct.analysis.application.dat.LRPSelectionWidthBean();
    resizeOCTSelectionMouseMonitor = new oct.analysis.application.comp.ResizeOCTSelectionMouseMonitor();
    octAnalysisPanel = new oct.analysis.application.OCTImagePanel();
    filterPanel = new javax.swing.JPanel();
    filtersToolbar = new javax.swing.JToolBar();
    jPanel1 = new javax.swing.JPanel();
    lrpSmoothingPanel = new javax.swing.JPanel();
    lrpSmoothingSlider = new javax.swing.JSlider();
    octSmoothingPanel = new javax.swing.JPanel();
    octSmoothingSlider = new javax.swing.JSlider();
    sharpRadiusPanel = new javax.swing.JPanel();
    octSharpRadiusSlider = new javax.swing.JSlider();
    octSharpWeightPanel = new javax.swing.JPanel();
    octSharpWeightSlider = new javax.swing.JSlider();
    analysisToolsToolBar = new javax.swing.JToolBar();
    foveaSelectButton = new javax.swing.JToggleButton();
    singleSelectButton = new javax.swing.JToggleButton();
    screenSelectButton = new javax.swing.JToggleButton();
    jLabel1 = new javax.swing.JLabel();
    lrpWidthTextField = new javax.swing.JFormattedTextField();
    displayPanel = new javax.swing.JPanel();
    positionPanel = new javax.swing.JPanel();
    mousePositionLabel = new oct.analysis.application.comp.MousePositionListeningLabel();
    filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0),
            new java.awt.Dimension(32767, 0));
    jPanel2 = new javax.swing.JPanel();
    mouseDistanceToFoveaLabel = new oct.analysis.application.comp.MouseDistanceToFoveaListeningLabel();
    filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0),
            new java.awt.Dimension(32767, 0));
    dispControlPanel = new javax.swing.JPanel();
    dispSelectionsCheckBox = new javax.swing.JCheckBox();
    filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0),
            new java.awt.Dimension(32767, 0));
    dispSegmentationCheckBox = new javax.swing.JCheckBox();
    filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0),
            new java.awt.Dimension(32767, 0));
    scaleBarCheckBox = new javax.swing.JCheckBox();
    filler5 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0),
            new java.awt.Dimension(32767, 0));
    imageLabel = new javax.swing.JLabel();
    logModeOCTButton = new javax.swing.JRadioButton();
    linearOCTModeButton = new javax.swing.JRadioButton();
    appMenuBar = new javax.swing.JMenuBar();
    fileMenu = new javax.swing.JMenu();
    newAnalysisMenuItem = new javax.swing.JMenuItem();
    openAnalysisMenuItem = new javax.swing.JMenuItem();
    saveAnalysisMenuItem = new javax.swing.JMenuItem();
    exportAnalysisResultsMenuItem = new javax.swing.JMenuItem();
    Exit = new javax.swing.JMenuItem();
    analysisMenu = new javax.swing.JMenu();
    equidistantAutoMenuItem = new javax.swing.JMenuItem();
    equidistantInteractiveMenuItem = new javax.swing.JMenuItem();
    autoEzMenuItem = new javax.swing.JMenuItem();
    interactiveEzMenuItem = new javax.swing.JMenuItem();
    singleLRPAnalysisMenuItem = new javax.swing.JMenuItem();
    autoMirrorMenuItem = new javax.swing.JMenuItem();
    interactiveMirrorAnalysisMenuItem = new javax.swing.JMenuItem();
    autoFoveaFindMenuItem = new javax.swing.JMenuItem();
    interactiveFindFoveaMenuItem = new javax.swing.JMenuItem();
    toolsMenu = new javax.swing.JMenu();
    foveaSelectMenuItem = new javax.swing.JCheckBoxMenuItem();
    singleSelectMenuItem = new javax.swing.JCheckBoxMenuItem();
    lrpMenuItem = new javax.swing.JMenuItem();
    toolbarsMenu = new javax.swing.JMenu();
    filtersTBMenuItem = new javax.swing.JCheckBoxMenuItem();

    org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(
            org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, lrpWidthTextField,
            org.jdesktop.beansbinding.ELProperty.create("${value}"), lrpSelectionWidthBean,
            org.jdesktop.beansbinding.BeanProperty.create("lrpSelectionWidth"));
    bindingGroup.addBinding(binding);

    lrpSelectionWidthBean.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
            lrpSelectionWidthBeanPropertyChange(evt);
        }
    });

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("OCT Reflectivity Analytics");
    setIconImage(new ImageIcon(getClass().getResource("/oct/rsc/icon/logo.png")).getImage());
    setLocationByPlatform(true);
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosed(java.awt.event.WindowEvent evt) {
            formWindowClosed(evt);
        }
    });

    octAnalysisPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    octAnalysisPanel.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            octAnalysisPanelMouseClicked(evt);
        }
    });
    octAnalysisPanel.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            octAnalysisPanelKeyPressed(evt);
        }

        public void keyTyped(java.awt.event.KeyEvent evt) {
            octAnalysisPanelKeyTyped(evt);
        }
    });

    javax.swing.GroupLayout octAnalysisPanelLayout = new javax.swing.GroupLayout(octAnalysisPanel);
    octAnalysisPanel.setLayout(octAnalysisPanelLayout);
    octAnalysisPanelLayout.setHorizontalGroup(octAnalysisPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE));
    octAnalysisPanelLayout.setVerticalGroup(octAnalysisPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE));

    filterPanel.setLayout(new java.awt.BorderLayout());

    filtersToolbar.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    filtersToolbar.setOrientation(javax.swing.SwingConstants.VERTICAL);
    filtersToolbar.setRollover(true);
    filtersToolbar.setName("OCT Filters Toolbar"); // NOI18N

    lrpSmoothingPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("LRP Smoothing Factor"));

    lrpSmoothingSlider.setMajorTickSpacing(5);
    lrpSmoothingSlider.setMaximum(51);
    lrpSmoothingSlider.setMinimum(1);
    lrpSmoothingSlider.setMinorTickSpacing(1);
    lrpSmoothingSlider.setPaintLabels(true);
    lrpSmoothingSlider.setPaintTicks(true);
    lrpSmoothingSlider.setSnapToTicks(true);
    lrpSmoothingSlider
            .setToolTipText("Adjust the smoothing applied to LRPs (values of 0 and 1 have the same effect)");
    lrpSmoothingSlider.setValue(5);
    lrpSmoothingSlider.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            lrpSmoothingSliderStateChanged(evt);
        }
    });

    javax.swing.GroupLayout lrpSmoothingPanelLayout = new javax.swing.GroupLayout(lrpSmoothingPanel);
    lrpSmoothingPanel.setLayout(lrpSmoothingPanelLayout);
    lrpSmoothingPanelLayout.setHorizontalGroup(
            lrpSmoothingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                    lrpSmoothingSlider, javax.swing.GroupLayout.DEFAULT_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
    lrpSmoothingPanelLayout.setVerticalGroup(
            lrpSmoothingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                    lrpSmoothingSlider, javax.swing.GroupLayout.DEFAULT_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));

    octSmoothingPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("OCT Smoothing Factor"));

    octSmoothingSlider.setMajorTickSpacing(5);
    octSmoothingSlider.setMaximum(50);
    octSmoothingSlider.setMinorTickSpacing(1);
    octSmoothingSlider.setPaintLabels(true);
    octSmoothingSlider.setPaintTicks(true);
    octSmoothingSlider.setSnapToTicks(true);
    octSmoothingSlider
            .setToolTipText("Adjust the smoothing of the OCT image (performed using a 3x3 Gausian blur)");
    octSmoothingSlider.setValue(0);
    octSmoothingSlider.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            octSmoothingSliderStateChanged(evt);
        }
    });

    javax.swing.GroupLayout octSmoothingPanelLayout = new javax.swing.GroupLayout(octSmoothingPanel);
    octSmoothingPanel.setLayout(octSmoothingPanelLayout);
    octSmoothingPanelLayout.setHorizontalGroup(
            octSmoothingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                    octSmoothingSlider, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE));
    octSmoothingPanelLayout.setVerticalGroup(
            octSmoothingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                    octSmoothingSlider, javax.swing.GroupLayout.Alignment.TRAILING,
                    javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE));

    sharpRadiusPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("OCT Sharpen Radius"));

    octSharpRadiusSlider.setMajorTickSpacing(20);
    octSharpRadiusSlider.setMaximum(200);
    octSharpRadiusSlider.setMinorTickSpacing(5);
    octSharpRadiusSlider.setPaintLabels(true);
    octSharpRadiusSlider.setPaintTicks(true);
    octSharpRadiusSlider.setSnapToTicks(true);
    octSharpRadiusSlider.setToolTipText(
            "Adjust the number of pixels (as a radius) used to sharpen OCT at each given point");
    octSharpRadiusSlider.setValue(0);
    octSharpRadiusSlider.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            octSharpRadiusSliderStateChanged(evt);
        }
    });

    javax.swing.GroupLayout sharpRadiusPanelLayout = new javax.swing.GroupLayout(sharpRadiusPanel);
    sharpRadiusPanel.setLayout(sharpRadiusPanelLayout);
    sharpRadiusPanelLayout.setHorizontalGroup(
            sharpRadiusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                    octSharpRadiusSlider, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE));
    sharpRadiusPanelLayout.setVerticalGroup(
            sharpRadiusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                    octSharpRadiusSlider, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE));

    octSharpWeightPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("OCT Sharpen Weight Factor"));

    octSharpWeightSlider.setMajorTickSpacing(10);
    octSharpWeightSlider.setMinorTickSpacing(2);
    octSharpWeightSlider.setPaintLabels(true);
    octSharpWeightSlider.setPaintTicks(true);
    octSharpWeightSlider.setToolTipText("Adjust the weighting factor given to the sharpened pixel information");
    octSharpWeightSlider.setValue(0);
    octSharpWeightSlider.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            octSharpWeightSliderStateChanged(evt);
        }
    });

    javax.swing.GroupLayout octSharpWeightPanelLayout = new javax.swing.GroupLayout(octSharpWeightPanel);
    octSharpWeightPanel.setLayout(octSharpWeightPanelLayout);
    octSharpWeightPanelLayout.setHorizontalGroup(
            octSharpWeightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(octSharpWeightSlider, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
    octSharpWeightPanelLayout.setVerticalGroup(octSharpWeightPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(octSharpWeightSlider,
                    javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 73,
                    javax.swing.GroupLayout.PREFERRED_SIZE));

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(octSmoothingPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(lrpSmoothingPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(sharpRadiusPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(octSharpWeightPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))));
    jPanel1Layout
            .setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(sharpRadiusPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(lrpSmoothingPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGap(6, 6, 6)
                            .addGroup(jPanel1Layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(octSharpWeightPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(octSmoothingPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(0, 0, Short.MAX_VALUE)));

    filtersToolbar.add(jPanel1);

    filterPanel.add(filtersToolbar, java.awt.BorderLayout.CENTER);
    filtersToolbar.addAncestorListener(new ToolbarFloatListener(filtersToolbar, this));

    analysisToolsToolBar.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    analysisToolsToolBar.setRollover(true);

    foveaSelectButton.setAction(foveaSelectMenuItem.getAction());
    toolsToolBarBtnGroup.add(foveaSelectButton);
    foveaSelectButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/oct/rsc/icon/FVselect.png"))); // NOI18N
    foveaSelectButton.setToolTipText("Fovea Selection Selector Tool");
    foveaSelectButton.setEnabled(false);
    foveaSelectButton.setFocusable(false);
    foveaSelectButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    foveaSelectButton.setSelectedIcon(
            new javax.swing.ImageIcon(getClass().getResource("/oct/rsc/icon/FVselectSelected.png"))); // NOI18N
    foveaSelectButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    foveaSelectButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            foveaSelectButtonActionPerformed(evt);
        }
    });
    analysisToolsToolBar.add(foveaSelectButton);

    singleSelectButton.setAction(singleSelectMenuItem.getAction());
    toolsToolBarBtnGroup.add(singleSelectButton);
    singleSelectButton
            .setIcon(new javax.swing.ImageIcon(getClass().getResource("/oct/rsc/icon/SingleSelectIcon.png"))); // NOI18N
    singleSelectButton.setToolTipText("Selection Selector Tool");
    singleSelectButton.setEnabled(false);
    singleSelectButton.setFocusable(false);
    singleSelectButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    singleSelectButton.setSelectedIcon(
            new javax.swing.ImageIcon(getClass().getResource("/oct/rsc/icon/SingleSelectSelectedIcon.png"))); // NOI18N
    singleSelectButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    singleSelectButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            singleSelectButtonActionPerformed(evt);
        }
    });
    analysisToolsToolBar.add(singleSelectButton);

    toolsToolBarBtnGroup.add(screenSelectButton);
    screenSelectButton.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/oct/rsc/icon/mouse-pointer-th_19x25.png"))); // NOI18N
    screenSelectButton.setToolTipText("Selection Pointer Tool");
    screenSelectButton.setEnabled(false);
    screenSelectButton.setFocusable(false);
    screenSelectButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    screenSelectButton.setName(""); // NOI18N
    screenSelectButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    screenSelectButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            screenSelectButtonActionPerformed(evt);
        }
    });
    analysisToolsToolBar.add(screenSelectButton);

    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel1.setLabelFor(lrpWidthTextField);
    jLabel1.setText("LRP Selection Width:");
    jLabel1.setToolTipText("Width (in pixels) of the LRP selections on the OCT");
    jLabel1.setFocusable(false);
    jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jLabel1.setMaximumSize(new java.awt.Dimension(105, 14));
    analysisToolsToolBar.add(jLabel1);

    lrpWidthTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(
            new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
    lrpWidthTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    lrpWidthTextField.setText("5");
    lrpWidthTextField.setToolTipText("Set the width of the LRP selections (in pixels)");
    lrpWidthTextField.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
    lrpWidthTextField.setMaximumSize(new java.awt.Dimension(35, 25));
    lrpWidthTextField.setMinimumSize(new java.awt.Dimension(35, 25));
    lrpWidthTextField.setPreferredSize(new java.awt.Dimension(35, 25));
    analysisToolsToolBar.add(lrpWidthTextField);

    displayPanel.setLayout(new javax.swing.BoxLayout(displayPanel, javax.swing.BoxLayout.LINE_AXIS));

    positionPanel.setBorder(javax.swing.BorderFactory
            .createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Position"));
    positionPanel.setPreferredSize(new java.awt.Dimension(80, 47));

    mousePositionLabel.setText("Mouse Position");

    javax.swing.GroupLayout positionPanelLayout = new javax.swing.GroupLayout(positionPanel);
    positionPanel.setLayout(positionPanelLayout);
    positionPanelLayout.setHorizontalGroup(
            positionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                    mousePositionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE));
    positionPanelLayout.setVerticalGroup(
            positionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                    mousePositionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE));

    displayPanel.add(positionPanel);
    displayPanel.add(filler1);

    jPanel2.setBorder(javax.swing.BorderFactory
            .createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "To Fovea"));
    jPanel2.setPreferredSize(new java.awt.Dimension(60, 47));

    mouseDistanceToFoveaLabel.setText("Distance");

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout
            .setHorizontalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(mouseDistanceToFoveaLabel, javax.swing.GroupLayout.Alignment.TRAILING,
                            javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE));
    jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                    mouseDistanceToFoveaLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE));

    displayPanel.add(jPanel2);
    displayPanel.add(filler4);

    dispControlPanel.setBorder(javax.swing.BorderFactory
            .createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Display Control"));
    dispControlPanel.setLayout(new javax.swing.BoxLayout(dispControlPanel, javax.swing.BoxLayout.LINE_AXIS));

    dispSelectionsCheckBox.setSelected(true);
    dispSelectionsCheckBox.setText("LRP Selections");
    dispSelectionsCheckBox.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            dispSelectionsCheckBoxStateChanged(evt);
        }
    });
    dispControlPanel.add(dispSelectionsCheckBox);
    dispControlPanel.add(filler2);

    dispSegmentationCheckBox.setText("Segmentation");
    dispSegmentationCheckBox.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            dispSegmentationCheckBoxStateChanged(evt);
        }
    });
    dispSegmentationCheckBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            dispSegmentationCheckBoxActionPerformed(evt);
        }
    });
    dispControlPanel.add(dispSegmentationCheckBox);
    dispControlPanel.add(filler3);

    scaleBarCheckBox.setText("Scale Bars");
    scaleBarCheckBox.setToolTipText("Show or hide scale bars on the image");
    scaleBarCheckBox.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            scaleBarCheckBoxStateChanged(evt);
        }
    });
    scaleBarCheckBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            scaleBarCheckBoxActionPerformed(evt);
        }
    });
    dispControlPanel.add(scaleBarCheckBox);
    dispControlPanel.add(filler5);

    imageLabel.setText("Image:");
    dispControlPanel.add(imageLabel);

    lrpButtonGroup.add(logModeOCTButton);
    logModeOCTButton.setSelected(true);
    logModeOCTButton.setText("Logrithmic OCT");
    logModeOCTButton.setToolTipText("Display the OCT image as a Logrithmic Image");
    logModeOCTButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            logModeOCTButtonActionPerformed(evt);
        }
    });
    dispControlPanel.add(logModeOCTButton);

    lrpButtonGroup.add(linearOCTModeButton);
    linearOCTModeButton.setText("Linear OCT");
    linearOCTModeButton.setToolTipText("Display the OCT image as a Linear Image");
    linearOCTModeButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            linearOCTModeButtonActionPerformed(evt);
        }
    });
    dispControlPanel.add(linearOCTModeButton);

    displayPanel.add(dispControlPanel);

    fileMenu.setText("File");

    newAnalysisMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N,
            java.awt.event.InputEvent.CTRL_MASK));
    newAnalysisMenuItem.setText("New Analysis");
    newAnalysisMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            newAnalysisMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(newAnalysisMenuItem);

    openAnalysisMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
            java.awt.event.InputEvent.CTRL_MASK));
    openAnalysisMenuItem.setText("Open Analysis");
    openAnalysisMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            openAnalysisMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(openAnalysisMenuItem);

    saveAnalysisMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
            java.awt.event.InputEvent.CTRL_MASK));
    saveAnalysisMenuItem.setText("Save Analysis");
    saveAnalysisMenuItem.setEnabled(false);
    saveAnalysisMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveAnalysisMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(saveAnalysisMenuItem);

    exportAnalysisResultsMenuItem.setAccelerator(javax.swing.KeyStroke
            .getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
    exportAnalysisResultsMenuItem.setText("Export Analysis Results");
    exportAnalysisResultsMenuItem.setEnabled(false);
    exportAnalysisResultsMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exportAnalysisResultsMenuItemActionPerformed(evt);
        }
    });
    fileMenu.add(exportAnalysisResultsMenuItem);

    Exit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q,
            java.awt.event.InputEvent.CTRL_MASK));
    Exit.setText("Quit");
    Exit.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ExitActionPerformed(evt);
        }
    });
    fileMenu.add(Exit);

    appMenuBar.add(fileMenu);

    analysisMenu.setText("Analysis");
    analysisMenu.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            analysisMenuActionPerformed(evt);
        }
    });

    equidistantAutoMenuItem.setText("Equidistant (automatic)");
    equidistantAutoMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            equidistantAutoMenuItemActionPerformed(evt);
        }
    });
    analysisMenu.add(equidistantAutoMenuItem);

    equidistantInteractiveMenuItem.setText("Equidistant (interactive)");
    equidistantInteractiveMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            equidistantInteractiveMenuItemActionPerformed(evt);
        }
    });
    analysisMenu.add(equidistantInteractiveMenuItem);

    autoEzMenuItem.setText("EZ (automatic)");
    autoEzMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            autoEzMenuItemActionPerformed(evt);
        }
    });
    analysisMenu.add(autoEzMenuItem);

    interactiveEzMenuItem.setText("EZ (interactive)");
    interactiveEzMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            interactiveEzMenuItemActionPerformed(evt);
        }
    });
    analysisMenu.add(interactiveEzMenuItem);

    singleLRPAnalysisMenuItem.setText("Single");
    singleLRPAnalysisMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            singleLRPAnalysisMenuItemActionPerformed(evt);
        }
    });
    analysisMenu.add(singleLRPAnalysisMenuItem);

    autoMirrorMenuItem.setText("Mirror (automatic)");
    autoMirrorMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            autoMirrorMenuItemActionPerformed(evt);
        }
    });
    analysisMenu.add(autoMirrorMenuItem);

    interactiveMirrorAnalysisMenuItem.setText("Mirror (interactive)");
    interactiveMirrorAnalysisMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            interactiveMirrorAnalysisMenuItemActionPerformed(evt);
        }
    });
    analysisMenu.add(interactiveMirrorAnalysisMenuItem);

    autoFoveaFindMenuItem.setText("Find Fovea (automatic)");
    autoFoveaFindMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            autoFoveaFindMenuItemActionPerformed(evt);
        }
    });
    analysisMenu.add(autoFoveaFindMenuItem);

    interactiveFindFoveaMenuItem.setText("Find Fovea (interactive)");
    interactiveFindFoveaMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            interactiveFindFoveaMenuItemActionPerformed(evt);
        }
    });
    analysisMenu.add(interactiveFindFoveaMenuItem);

    appMenuBar.add(analysisMenu);

    toolsMenu.setText("Tools");
    toolsMenu.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            toolsMenuActionPerformed(evt);
        }
    });

    foveaSelectMenuItem.setText("Select Fovea");
    foveaSelectMenuItem.setEnabled(false);
    foveaSelectMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            foveaSelectMenuItemActionPerformed(evt);
        }
    });
    toolsMenu.add(foveaSelectMenuItem);

    singleSelectMenuItem.setText("Select Single");
    singleSelectMenuItem.setEnabled(false);
    singleSelectMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            singleSelectMenuItemActionPerformed(evt);
        }
    });
    toolsMenu.add(singleSelectMenuItem);

    lrpMenuItem.setText("Generate LRPs");
    lrpMenuItem.setEnabled(false);
    lrpMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            lrpMenuItemActionPerformed(evt);
        }
    });
    toolsMenu.add(lrpMenuItem);

    appMenuBar.add(toolsMenu);

    toolbarsMenu.setText("Toolbars");

    filtersTBMenuItem.setSelected(true);
    filtersTBMenuItem.setText("Filters Toolbar");
    filtersTBMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            filtersTBMenuItemActionPerformed(evt);
        }
    });
    toolbarsMenu.add(filtersTBMenuItem);

    appMenuBar.add(toolbarsMenu);

    setJMenuBar(appMenuBar);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(octAnalysisPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(displayPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 736, Short.MAX_VALUE))
            .addComponent(filterPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(analysisToolsToolBar, javax.swing.GroupLayout.DEFAULT_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                    .addComponent(analysisToolsToolBar, javax.swing.GroupLayout.PREFERRED_SIZE, 39,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(octAnalysisPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(displayPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 47,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(filterPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));

    analysisToolsToolBar.setFloatable(false);

    bindingGroup.bind();

    pack();
}

From source file:org.sikuli.ide.SikuliIDE.java

private void initFileMenu() throws NoSuchMethodException {
    JMenuItem jmi;/*from  ww  w.ja  v  a2s. co  m*/
    int scMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    _fileMenu.setMnemonic(java.awt.event.KeyEvent.VK_F);

    if (showAbout) {
        _fileMenu.add(
                createMenuItem("About SikuliX", KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, scMask),
                        new FileAction(FileAction.ABOUT)));
        _fileMenu.addSeparator();
    }

    _fileMenu.add(createMenuItem(_I("menuFileNew"),
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, scMask), new FileAction(FileAction.NEW)));

    jmi = _fileMenu.add(createMenuItem(_I("menuFileOpen"),
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, scMask), new FileAction(FileAction.OPEN)));
    jmi.setName("OPEN");

    recentMenu = new JMenu(_I("menuRecent"));

    if (Settings.experimental) {
        _fileMenu.add(recentMenu);
    }

    if (Settings.isMac() && !Settings.handlesMacBundles) {
        _fileMenu.add(createMenuItem("Open folder.sikuli ...", null,
                //            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, scMask),
                new FileAction(FileAction.OPEN_FOLDER)));
    }

    jmi = _fileMenu.add(createMenuItem(_I("menuFileSave"),
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, scMask), new FileAction(FileAction.SAVE)));
    jmi.setName("SAVE");

    jmi = _fileMenu.add(createMenuItem(_I("menuFileSaveAs"),
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, InputEvent.SHIFT_MASK | scMask),
            new FileAction(FileAction.SAVE_AS)));
    jmi.setName("SAVE_AS");

    if (Settings.isMac() && !Settings.handlesMacBundles) {
        _fileMenu.add(createMenuItem(_I("Save as folder.sikuli ..."),
                //            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
                //            InputEvent.SHIFT_MASK | scMask),
                null, new FileAction(FileAction.SAVE_AS_FOLDER)));
    }

    //TODO    _fileMenu.add(createMenuItem(_I("menuFileSaveAll"),
    _fileMenu.add(createMenuItem("Save all",
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, InputEvent.CTRL_MASK | scMask),
            new FileAction(FileAction.SAVE_ALL)));

    _fileMenu.add(createMenuItem(_I("menuFileExport"),
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, InputEvent.SHIFT_MASK | scMask),
            new FileAction(FileAction.EXPORT)));

    jmi = _fileMenu.add(
            createMenuItem(_I("menuFileCloseTab"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, scMask),
                    new FileAction(FileAction.CLOSE_TAB)));
    jmi.setName("CLOSE_TAB");

    if (showPrefs) {
        _fileMenu.addSeparator();
        _fileMenu.add(createMenuItem(_I("menuFilePreferences"),
                KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, scMask),
                new FileAction(FileAction.PREFERENCES)));
    }

    if (showQuit) {
        _fileMenu.addSeparator();
        _fileMenu.add(createMenuItem(_I("menuFileQuit"), null, new FileAction(FileAction.QUIT)));
    }
}

From source file:pl.otros.logview.gui.LogViewMainFrame.java

private void initToolbar() {
    toolBar = new JToolBar();
    final JComboBox searchMode = new JComboBox(
            new String[] { "String contains search: ", "Regex search: ", "Query search: " });
    final SearchAction searchActionForward = new SearchAction(otrosApplication, SearchDirection.FORWARD);
    final SearchAction searchActionBackward = new SearchAction(otrosApplication, SearchDirection.REVERSE);
    searchFieldCbxModel = new DefaultComboBoxModel();
    searchField = new JXComboBox(searchFieldCbxModel);
    searchField.setEditable(true);/* w  w w  .  j a  va  2s.c o  m*/
    AutoCompleteDecorator.decorate(searchField);
    searchField.setMinimumSize(new Dimension(150, 10));
    searchField.setPreferredSize(new Dimension(250, 10));
    searchField.setToolTipText(
            "<HTML>Enter text to search.<BR/>" + "Enter - search next,<BR/>Alt+Enter search previous,<BR/>"
                    + "Ctrl+Enter - mark all found</HTML>");
    final DelayedSwingInvoke delayedSearchResultUpdate = new DelayedSwingInvoke() {
        @Override
        protected void performActionHook() {
            JTextComponent editorComponent = (JTextComponent) searchField.getEditor().getEditorComponent();
            int stringEnd = editorComponent.getSelectionStart();
            if (stringEnd < 0) {
                stringEnd = editorComponent.getText().length();
            }
            try {
                String selectedText = editorComponent.getText(0, stringEnd);
                if (StringUtils.isBlank(selectedText)) {
                    return;
                }
                OtrosJTextWithRulerScrollPane<JTextPane> logDetailWithRulerScrollPane = otrosApplication
                        .getSelectedLogViewPanel().getLogDetailWithRulerScrollPane();
                MessageUpdateUtils.highlightSearchResult(logDetailWithRulerScrollPane,
                        otrosApplication.getAllPluginables().getMessageColorizers());
                RulerBarHelper.scrollToFirstMarker(logDetailWithRulerScrollPane);
            } catch (BadLocationException e) {
                LOGGER.log(Level.SEVERE, "Can't update search highlight", e);
            }
        }
    };
    JTextComponent searchFieldTextComponent = (JTextComponent) searchField.getEditor().getEditorComponent();
    searchFieldTextComponent.getDocument().addDocumentListener(new DocumentInsertUpdateHandler() {
        @Override
        protected void documentChanged(DocumentEvent e) {
            delayedSearchResultUpdate.performAction();
        }
    });
    final MarkAllFoundAction markAllFoundAction = new MarkAllFoundAction(otrosApplication);
    final SearchModeValidatorDocumentListener searchValidatorDocumentListener = new SearchModeValidatorDocumentListener(
            (JTextField) searchField.getEditor().getEditorComponent(), observer, SearchMode.STRING_CONTAINS);
    SearchMode searchModeFromConfig = configuration.get(SearchMode.class, "gui.searchMode",
            SearchMode.STRING_CONTAINS);
    final String lastSearchString;
    int selectedSearchMode = 0;
    if (searchModeFromConfig.equals(SearchMode.STRING_CONTAINS)) {
        selectedSearchMode = 0;
        lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_STRING, "");
    } else if (searchModeFromConfig.equals(SearchMode.REGEX)) {
        selectedSearchMode = 1;
        lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_REGEX, "");
    } else if (searchModeFromConfig.equals(SearchMode.QUERY)) {
        selectedSearchMode = 2;
        lastSearchString = configuration.getString(ConfKeys.SEARCH_LAST_QUERY, "");
    } else {
        LOGGER.warning("Unknown search mode " + searchModeFromConfig);
        lastSearchString = "";
    }
    Component editorComponent = searchField.getEditor().getEditorComponent();
    if (editorComponent instanceof JTextField) {
        final JTextField sfTf = (JTextField) editorComponent;
        sfTf.getDocument().addDocumentListener(searchValidatorDocumentListener);
        sfTf.getDocument().addDocumentListener(new DocumentInsertUpdateHandler() {
            @Override
            protected void documentChanged(DocumentEvent e) {
                try {
                    int length = e.getDocument().getLength();
                    if (length > 0) {
                        searchResultColorizer.setSearchString(e.getDocument().getText(0, length));
                    }
                } catch (BadLocationException e1) {
                    LOGGER.log(Level.SEVERE, "Error: ", e1);
                }
            }
        });
        sfTf.addKeyListener(new SearchFieldKeyListener(searchActionForward, sfTf));
        sfTf.setText(lastSearchString);
    }
    searchMode.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            SearchMode mode = null;
            boolean validationEnabled = false;
            String confKey = null;
            String lastSearch = ((JTextField) searchField.getEditor().getEditorComponent()).getText();
            if (searchMode.getSelectedIndex() == 0) {
                mode = SearchMode.STRING_CONTAINS;
                searchValidatorDocumentListener.setSearchMode(mode);
                validationEnabled = false;
                searchMode.setToolTipText("Checking if log message contains string (case is ignored)");
                confKey = ConfKeys.SEARCH_LAST_STRING;
            } else if (searchMode.getSelectedIndex() == 1) {
                mode = SearchMode.REGEX;
                validationEnabled = true;
                searchMode
                        .setToolTipText("Checking if log message matches regular expression (case is ignored)");
                confKey = ConfKeys.SEARCH_LAST_REGEX;
            } else if (searchMode.getSelectedIndex() == 2) {
                mode = SearchMode.QUERY;
                validationEnabled = true;
                String querySearchTooltip = "<HTML>" + //
                "Advance search using SQL-like quries (i.e. level>=warning && msg~=failed && thread==t1)<BR/>" + //
                "Valid operator for query search is ==, ~=, !=, LIKE, EXISTS, <, <=, >, >=, &&, ||, ! <BR/>" + //
                "See wiki for more info<BR/>" + //
                "</HTML>";
                searchMode.setToolTipText(querySearchTooltip);
                confKey = ConfKeys.SEARCH_LAST_QUERY;
            }
            searchValidatorDocumentListener.setSearchMode(mode);
            searchValidatorDocumentListener.setEnable(validationEnabled);
            searchActionForward.setSearchMode(mode);
            searchActionBackward.setSearchMode(mode);
            markAllFoundAction.setSearchMode(mode);
            configuration.setProperty("gui.searchMode", mode);
            searchResultColorizer.setSearchMode(mode);
            List<Object> list = configuration.getList(confKey);
            searchFieldCbxModel.removeAllElements();
            for (Object o : list) {
                searchFieldCbxModel.addElement(o);
            }
            searchField.setSelectedItem(lastSearch);
        }
    });
    searchMode.setSelectedIndex(selectedSearchMode);
    final JCheckBox markFound = new JCheckBox("Mark search result");
    markFound.setMnemonic(KeyEvent.VK_M);
    searchField.addKeyListener(markAllFoundAction);
    configuration.addConfigurationListener(markAllFoundAction);
    JButton markAllFoundButton = new JButton(markAllFoundAction);
    final JComboBox markColor = new JComboBox(MarkerColors.values());
    markFound.setSelected(configuration.getBoolean("gui.markFound", true));
    markFound.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            boolean selected = markFound.isSelected();
            searchActionForward.setMarkFound(selected);
            searchActionBackward.setMarkFound(selected);
            configuration.setProperty("gui.markFound", markFound.isSelected());
        }
    });
    markColor.setRenderer(new MarkerColorsComboBoxRenderer());
    //      markColor.addActionListener(new ActionListener() {
    //
    //         @Override
    //         public void actionPerformed(ActionEvent e) {
    //            MarkerColors markerColors = (MarkerColors) markColor.getSelectedItem();
    //            searchActionForward.setMarkerColors(markerColors);
    //            searchActionBackward.setMarkerColors(markerColors);
    //            markAllFoundAction.setMarkerColors(markerColors);
    //            configuration.setProperty("gui.markColor", markColor.getSelectedItem());
    //            otrosApplication.setSelectedMarkColors(markerColors);
    //         }
    //      });
    markColor.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            MarkerColors markerColors = (MarkerColors) markColor.getSelectedItem();
            searchActionForward.setMarkerColors(markerColors);
            searchActionBackward.setMarkerColors(markerColors);
            markAllFoundAction.setMarkerColors(markerColors);
            configuration.setProperty("gui.markColor", markColor.getSelectedItem());
            otrosApplication.setSelectedMarkColors(markerColors);
        }
    });
    markColor.getModel()
            .setSelectedItem(configuration.get(MarkerColors.class, "gui.markColor", MarkerColors.Aqua));
    buttonSearch = new JButton(searchActionForward);
    buttonSearch.setMnemonic(KeyEvent.VK_N);
    JButton buttonSearchPrev = new JButton(searchActionBackward);
    buttonSearchPrev.setMnemonic(KeyEvent.VK_P);
    enableDisableComponetsForTabs.addComponet(buttonSearch);
    enableDisableComponetsForTabs.addComponet(buttonSearchPrev);
    enableDisableComponetsForTabs.addComponet(searchField);
    enableDisableComponetsForTabs.addComponet(markFound);
    enableDisableComponetsForTabs.addComponet(markAllFoundButton);
    enableDisableComponetsForTabs.addComponet(searchMode);
    enableDisableComponetsForTabs.addComponet(markColor);
    toolBar.add(searchMode);
    toolBar.add(searchField);
    toolBar.add(buttonSearch);
    toolBar.add(buttonSearchPrev);
    toolBar.add(markFound);
    toolBar.add(markAllFoundButton);
    toolBar.add(markColor);
    JButton nextMarked = new JButton(new JumpToMarkedAction(otrosApplication, Direction.FORWARD));
    nextMarked.setToolTipText(nextMarked.getText());
    nextMarked.setText("");
    nextMarked.setMnemonic(KeyEvent.VK_E);
    enableDisableComponetsForTabs.addComponet(nextMarked);
    toolBar.add(nextMarked);
    JButton prevMarked = new JButton(new JumpToMarkedAction(otrosApplication, Direction.BACKWARD));
    prevMarked.setToolTipText(prevMarked.getText());
    prevMarked.setText("");
    prevMarked.setMnemonic(KeyEvent.VK_R);
    enableDisableComponetsForTabs.addComponet(prevMarked);
    toolBar.add(prevMarked);
    enableDisableComponetsForTabs.addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.INFO)));
    enableDisableComponetsForTabs
            .addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.WARNING)));
    enableDisableComponetsForTabs
            .addComponet(toolBar.add(new SearchByLevel(otrosApplication, 1, Level.SEVERE)));
    enableDisableComponetsForTabs.addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.INFO)));
    enableDisableComponetsForTabs
            .addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.WARNING)));
    enableDisableComponetsForTabs
            .addComponet(toolBar.add(new SearchByLevel(otrosApplication, -1, Level.SEVERE)));
}

From source file:haven.GameUI.java

public boolean globtype(char key, KeyEvent ev) {
    if (key == ':') {
        entercmd();/*from w w w.j ava 2s  . com*/
        return (true);
    } else if (key == ' ') {
        toggleui();
        return (true);
    } else if (key == 3) {
        if (chat.visible && !chat.hasfocus) {
            setfocus(chat);
        } else {
            if (chat.sz.y == 0) {
                chat.resize(chat.savedw, chat.savedh);
                setfocus(chat);
            } else {
                chat.resize(0, 0);
            }
        }
        Utils.setprefb("chatvis", chat.sz.y != 0);
    } else if (key == 16) {
        /*
        if((polity != null) && polity.show(!polity.visible)) {
        polity.raise();
        fitwdg(polity);
        setfocus(polity);
        }
        */
        return (true);
    } else if ((key == 27) && (map != null) && !map.hasfocus) {
        setfocus(map);
        return (true);
    } else if (key != 0) {
        boolean alt = ev.isAltDown();
        boolean ctrl = ev.isControlDown();
        boolean shift = ev.isShiftDown();
        int keycode = ev.getKeyCode();
        if (alt && keycode >= KeyEvent.VK_0 && keycode <= KeyEvent.VK_9) {
            beltwdg.setCurrentBelt(Utils.floormod(keycode - KeyEvent.VK_0 - 1, 10));
            return true;
        } else if (alt && keycode == KeyEvent.VK_S) {
            studywnd.show(!studywnd.visible);
            if (studywnd.visible)
                studywnd.raise();
            return true;
        } else if (alt && keycode == KeyEvent.VK_M) {
            if (mmapwnd != null) {
                mmapwnd.togglefold();
                return true;
            }
        } else if (alt && keycode == KeyEvent.VK_C) {
            craftwnd.show(!craftwnd.visible);
            if (craftwnd.visible)
                craftwnd.raise();
            return true;
        } else if (alt && keycode == KeyEvent.VK_B) {
            buildwnd.toggle();
            if (buildwnd.visible)
                buildwnd.raise();
            return true;
        } else if (alt && keycode == KeyEvent.VK_N) {
            Config.nightvision.set(!Config.nightvision.get());
        } else if (alt && keycode == KeyEvent.VK_G) {
            if (map != null)
                map.gridOverlay.setVisible(!map.gridOverlay.isVisible());
            return true;
        } else if (alt && keycode == KeyEvent.VK_R) {
            if (mmap != null)
                mmap.toggleCustomIcons();
            return true;
        } else if (alt && keycode == KeyEvent.VK_D) {
            if (map != null)
                map.toggleGobRadius();
            return true;
        } else if (alt && keycode == KeyEvent.VK_Q) {
            Config.showQuality.set(!Config.showQuality.get());
            return true;
        } else if (alt && keycode == KeyEvent.VK_K) {
            deckwnd.show(!deckwnd.visible);
            deckwnd.c = new Coord(sz.sub(deckwnd.sz).div(2));
            if (deckwnd.visible)
                deckwnd.raise();
            return true;
        } else if (alt && keycode == KeyEvent.VK_F) {
            if (map != null) {
                map.toggleFriendlyFire();
                msg("Friendly fire prevention is now turned "
                        + (map.isPreventFriendlyFireEnabled() ? "on" : "off"));
            }
            return true;
        } else if (alt && keycode == KeyEvent.VK_I) {
            Config.showGobInfo.set(!Config.showGobInfo.get());
            return true;
        } else if (alt && keycode == KeyEvent.VK_W) {
            Config.screenshotMode = !Config.screenshotMode;
            return true;
        } else if (alt && keycode == KeyEvent.VK_T) {
            Config.disableTileTransitions.set(!Config.disableTileTransitions.get());
            ui.sess.glob.map.rebuild();
            return true;
        } else if (keycode == KeyEvent.VK_Q && ev.getModifiers() == 0) {
            /*
            // get all forageables from config
            List<String> names = new ArrayList<String>();
            for (CustomIconGroup group : ui.sess.glob.icons.config.groups) {
                if ("Forageables".equals(group.name)) {
            for (CustomIconMatch match : group.matches)
                if (match.show)
                    names.add(match.value);
            break;
                }
            }
            tasks.add(new Forager(11 * Config.autopickRadius.get(), 1, names.toArray(new String[names.size()]))); 
            */
            ContextTaskFinder.checkForageables(tasks, ui);
            return true;
        } else if (keycode == KeyEvent.VK_E && ev.getModifiers() == 0) {
            ContextTaskFinder.findHandTask(tasks, ui);
            return true;
        } else if (keycode == KeyEvent.VK_F && ev.getModifiers() == 0) {
            ContextTaskFinder.findBuilding(tasks, ui);
            return true;
        } else if (keycode >= KeyEvent.VK_NUMPAD1 && keycode <= KeyEvent.VK_NUMPAD4) {
            tasks.add(new MileStoneTask(Utils.floormod(keycode - KeyEvent.VK_NUMPAD0 - 1, 10)));
            return true;
        } else if (keycode == KeyEvent.VK_W && ev.getModifiers() == 0) {
            tasks.add(new Drunkard());
            return true;
        } else if (shift && keycode == KeyEvent.VK_I) {
            Config.hideKinInfoForNonPlayers.set(!Config.hideKinInfoForNonPlayers.get());
            return true;
        } else if (ctrl && keycode == KeyEvent.VK_H) {
            Config.hideModeEnabled.set(!Config.hideModeEnabled.get());
            return true;
        } else if (alt && keycode == KeyEvent.VK_P) {
            Config.showGobPaths.set(!Config.showGobPaths.get());
            return true;
        } else if (shift && keycode == KeyEvent.VK_W) {
            if (Config.showQualityMode.get() == 1) {
                Config.showQualityMode.set(2);
            } else {
                Config.showQualityMode.set(1);
            }
            return true;
        } else if (keycode == KeyEvent.VK_TAB && Config.agroclosest.get()) {
            if (map != null)
                map.aggroclosest();
            return true;
        } else if (ctrl && keycode == KeyEvent.VK_F) {
            Config.displayFPS.set(!Config.displayFPS.get());
            return true;
        } else if (keycode == KeyEvent.VK_Z && ev.getModifiers() == 0) {
            tasks.killAllTasks();
            return true;
        } else if (keycode == 192 && ev.getModifiers() == 0) {
            getparent(GameUI.class).menu.wdgmsg("act", "travel", "hearth");
            return true;
        } else if (shift && keycode == KeyEvent.VK_S) {
            HavenPanel.screenshot = true;
            return true;
        }
    }
    return (super.globtype(key, ev));
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.analise_geral.PanelAnaliseGeral.java

/**
 * Cria o menu editar do Frame Principal
 * //from w w  w .j  ava2s  . c  om
 * @param menu
 */
private JMenu criaMenuEditar() {
    JMenu menu = new JMenu(GERAL.EDITAR);
    menu.setBackground(parentFrame.corDefault);
    menu.setMnemonic('E');
    menu.setMnemonic(KeyEvent.VK_E);

    JMenuItem btnContraste = new JMenuItem(GERAL.ALTERAR_CONTRASTE);
    btnContraste.addActionListener(this);
    btnContraste.setActionCommand("Contraste");
    // btnAumenta.setMnemonic('F');
    // btnAumenta.setMnemonic(KeyEvent.VK_F);
    // btnAumenta.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD,
    // ActionEvent.CTRL_MASK));
    btnContraste.setToolTipText(GERAL.DICA_CONTRASTE);
    btnContraste.getAccessibleContext().setAccessibleDescription(GERAL.DICA_CONTRASTE);
    menu.add(btnContraste);

    JMenuItem btnAumenta = new JMenuItem(GERAL.AUMENTA_FONTE);
    btnAumenta.addActionListener(this);
    btnAumenta.setActionCommand("AumentaFonte");
    // btnAumenta.setMnemonic('F');
    // btnAumenta.setMnemonic(KeyEvent.VK_F);
    btnAumenta.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, ActionEvent.CTRL_MASK));
    btnAumenta.setToolTipText(GERAL.DICA_AUMENTA_FONTE);
    btnAumenta.getAccessibleContext().setAccessibleDescription(GERAL.DICA_AUMENTA_FONTE);
    menu.add(btnAumenta);

    JMenuItem btnDiminui = new JMenuItem(GERAL.DIMINUI_FONTE);
    btnDiminui.addActionListener(this);
    btnDiminui.setActionCommand("DiminuiFonte");
    // btnDiminui.setMnemonic('F');
    // btnDiminui.setMnemonic(KeyEvent.VK_F);
    btnDiminui.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_SUBTRACT, ActionEvent.CTRL_MASK));
    btnDiminui.setToolTipText(GERAL.DICA_DIMINUI_FONTE);
    btnDiminui.getAccessibleContext().setAccessibleDescription(GERAL.DICA_DIMINUI_FONTE);
    menu.add(btnDiminui);

    menu.add(new JSeparator());

    JMenuItem btnProcurar = new JMenuItem(GERAL.PROCURAR);
    btnProcurar.addActionListener(this);
    btnProcurar.setActionCommand("Procurar");
    btnProcurar.setMnemonic('P');
    btnProcurar.setMnemonic(KeyEvent.VK_P);
    btnProcurar.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, ActionEvent.CTRL_MASK));
    btnProcurar.setToolTipText(GERAL.DICA_PROCURAR);
    btnProcurar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_PROCURAR);
    menu.add(btnProcurar);

    JMenuItem btnSelecionarTudo = new JMenuItem(GERAL.SELECIONAR_TUDO);
    btnSelecionarTudo.addActionListener(this);
    btnSelecionarTudo.setActionCommand("SelecionarTudo");
    btnSelecionarTudo.setMnemonic('T');
    btnSelecionarTudo.setMnemonic(KeyEvent.VK_T);
    btnSelecionarTudo.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, ActionEvent.CTRL_MASK));
    btnSelecionarTudo.setToolTipText(GERAL.DICA_SELECIONAR_TUDO);
    btnSelecionarTudo.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SELECIONAR_TUDO);
    menu.add(btnSelecionarTudo);

    JMenuItem btnDesfazer = new JMenuItem(GERAL.DESFAZER);
    btnDesfazer.addActionListener(this);
    btnDesfazer.setActionCommand("Desfazer");
    btnDesfazer.setMnemonic('z');
    btnDesfazer.setMnemonic(KeyEvent.VK_Z);
    btnDesfazer.getAccessibleContext().setAccessibleDescription(GERAL.DICA_DESFAZER);
    btnDesfazer.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, ActionEvent.CTRL_MASK));
    menu.add(btnDesfazer);
    menu.setEnabled(true);
    return menu;
}