Example usage for java.awt.event KeyEvent VK_I

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

Introduction

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

Prototype

int VK_I

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

Click Source Link

Document

Constant for the "I" key.

Usage

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

/**
 * This method initializes jMenuItemBrowseImages   
 *    /*from  w  w w.ja  v  a2s . c  om*/
 * @return javax.swing.JMenuItem   
 */
private JMenuItem getJMenuItemBrowseImages() {
    if (jMenuItemBrowseImages == null) {
        jMenuItemBrowseImages = new JMenuItem();
        jMenuItemBrowseImages.setText("Browse Image Files");
        jMenuItemBrowseImages.setMnemonic(KeyEvent.VK_I);
        try {
            jMenuItemBrowseImages.setIcon(new ImageIcon(this.getClass()
                    .getResource("/edu/harvard/mcz/imagecapture/resources/image_icon_16px.png")));
        } catch (Exception e) {
            log.error("Can't open icon file for jMenuItemBrowseImages.");
            log.error(e);
        }
        jMenuItemBrowseImages.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                // Create a ImageListBrowser jpanel and replace the 
                // the content of the center of jPanelCenter with it.
                //TODO: extend beyond switching between ilb and slb.
                Singleton.getSingletonInstance().getMainFrame()
                        .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                ilb = new ImageListBrowser();
                if (slb != null) {
                    jPanelCenter.remove(slb);
                }
                if (ulb != null) {
                    jPanelCenter.remove(ulb);
                }
                jPanelCenter.removeAll();
                jPanelCenter.add(ilb, BorderLayout.CENTER);
                jPanelCenter.revalidate();
                jPanelCenter.repaint();
                if (Singleton.getSingletonInstance().getProperties().getProperties()
                        .getProperty(ImageCaptureProperties.KEY_ENABLE_BROWSE).equals("false")) {
                    jMenuItemBrowseSpecimens.setEnabled(false);
                    jMenuItemBrowseImages.setEnabled(false);
                } else {
                    jMenuItemBrowseSpecimens.setEnabled(true);
                    jMenuItemBrowseImages.setEnabled(true);
                }
                setStatusMessage("Found " + ilb.getRowCount() + " images.");
                Singleton.getSingletonInstance().getMainFrame()
                        .setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                System.gc();
            }
        });
    }
    if (Singleton.getSingletonInstance().getProperties().getProperties()
            .getProperty(ImageCaptureProperties.KEY_ENABLE_BROWSE).equals("false")) {
        jMenuItemBrowseImages.setEnabled(false);
    }
    return jMenuItemBrowseImages;
}

From source file:GUI.MainWindow.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.//from   w w  w  .j a v a  2 s  . co m
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    ImportScanScreen = new javax.swing.JDialog();
    jLabel1 = new javax.swing.JLabel();
    jScrollPane2 = new javax.swing.JScrollPane();
    ImportFile = new javax.swing.JList();
    jLabel2 = new javax.swing.JLabel();
    FileType = new javax.swing.JTextField();
    jLabel3 = new javax.swing.JLabel();
    FileSize = new javax.swing.JTextField();
    ProgressBar = new javax.swing.JProgressBar();
    VulnTreeContextMenu = new javax.swing.JPopupMenu();
    MergeButton = new javax.swing.JMenuItem();
    LookupCVE = new javax.swing.JMenuItem();
    AddToPersonalVulns = new javax.swing.JMenuItem();
    ClearHash = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JPopupMenu.Separator();
    DeleteButton = new javax.swing.JMenuItem();
    VulnAffectedHostsContextMenu = new javax.swing.JPopupMenu();
    AddHostsButton = new javax.swing.JMenuItem();
    EditHostname = new javax.swing.JMenuItem();
    jSeparator2 = new javax.swing.JPopupMenu.Separator();
    DeleteHost = new javax.swing.JMenuItem();
    VulnReferencesContextMenu = new javax.swing.JPopupMenu();
    InsertReference = new javax.swing.JMenuItem();
    EditReferenceOption = new javax.swing.JMenuItem();
    LaunchInBrowser = new javax.swing.JMenuItem();
    jSeparator3 = new javax.swing.JPopupMenu.Separator();
    DeleteReferenceOption = new javax.swing.JMenuItem();
    ManageAffectedHosts = new javax.swing.JDialog();
    jScrollPane5 = new javax.swing.JScrollPane();
    ListOfHosts = new javax.swing.JList();
    jScrollPane9 = new javax.swing.JScrollPane();
    ListOfOpenPorts = new javax.swing.JList();
    jLabel5 = new javax.swing.JLabel();
    jLabel13 = new javax.swing.JLabel();
    MainScreenBottomPanel = new javax.swing.JPanel();
    jLabel20 = new javax.swing.JLabel();
    VulnTreeFilter = new javax.swing.JTextField();
    ExtraInfoLabel = new javax.swing.JLabel();
    jSplitPane2 = new javax.swing.JSplitPane();
    ViewModeTabPane = new javax.swing.JTabbedPane();
    jScrollPane1 = new javax.swing.JScrollPane();
    VulnTree = new javax.swing.JTree();
    jScrollPane3 = new javax.swing.JScrollPane();
    HostTree = new javax.swing.JTree();
    RightPanelCardLayout = new javax.swing.JPanel();
    RightPanelVulnView = new javax.swing.JPanel();
    VulnerabilityTopPanel = new javax.swing.JPanel();
    jPanel8 = new javax.swing.JPanel();
    jLabel9 = new javax.swing.JLabel();
    VulnTitleTextField = new javax.swing.JTextField();
    jPanel9 = new javax.swing.JPanel();
    jLabel10 = new javax.swing.JLabel();
    VulnCVSSVectorTextField = new javax.swing.JTextField();
    jLabel11 = new javax.swing.JLabel();
    VulnRiskCategory = new javax.swing.JTextField();
    jLabel12 = new javax.swing.JLabel();
    VulnScore = new javax.swing.JTextField();
    EditRiskButton = new javax.swing.JButton();
    jSplitPane1 = new javax.swing.JSplitPane();
    jSplitPane3 = new javax.swing.JSplitPane();
    VulnRecommendationsPanel = new javax.swing.JPanel();
    jLabel8 = new javax.swing.JLabel();
    jScrollPane7 = new javax.swing.JScrollPane();
    VulnRecommendationTextPane = new javax.swing.JTextPane();
    jSplitPane4 = new javax.swing.JSplitPane();
    VulnReferencesPanel = new javax.swing.JPanel();
    jLabel4 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jScrollPane6 = new javax.swing.JScrollPane();
    VulnReferencesList = new javax.swing.JList();
    jScrollPane4 = new javax.swing.JScrollPane();
    VulnAffectedHostsTable = new javax.swing.JTable();
    VulnDescriptionPanel = new javax.swing.JPanel();
    jLabel6 = new javax.swing.JLabel();
    jScrollPane8 = new javax.swing.JScrollPane();
    VulnDescriptionTextPane = new javax.swing.JTextPane();
    RightPanelHostsView = new javax.swing.JPanel();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenuItem3 = new javax.swing.JMenuItem();
    jMenuItem4 = new javax.swing.JMenuItem();
    jMenuItem5 = new javax.swing.JMenuItem();
    jMenuItem11 = new javax.swing.JMenuItem();
    exitButton = new javax.swing.JMenuItem();
    jMenu2 = new javax.swing.JMenu();
    jMenuItem1 = new javax.swing.JMenuItem();
    jMenuItem2 = new javax.swing.JMenuItem();
    jMenuItem7 = new javax.swing.JMenuItem();
    jMenuItem10 = new javax.swing.JMenuItem();
    jMenu4 = new javax.swing.JMenu();
    jMenuItem9 = new javax.swing.JMenuItem();
    jMenu3 = new javax.swing.JMenu();
    jMenuItem8 = new javax.swing.JMenuItem();
    jMenu5 = new javax.swing.JMenu();
    increaseFont = new javax.swing.JMenuItem();
    decreaseFont = new javax.swing.JMenuItem();

    ImportScanScreen.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    ImportScanScreen.setTitle("Report Compiler - Import Scan Screen");
    ImportScanScreen.setMinimumSize(new java.awt.Dimension(382, 220));
    ImportScanScreen.setModal(true);
    ImportScanScreen.addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowActivated(java.awt.event.WindowEvent evt) {
            ImportScanScreenWindowActivated(evt);
        }
    });

    jLabel1.setText("File Name:");

    ImportFile.setModel(new javax.swing.AbstractListModel() {
        String[] strings = { "One" };

        public int getSize() {
            return strings.length;
        }

        public Object getElementAt(int i) {
            return strings[i];
        }
    });
    ImportFile.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    ImportFile.setEnabled(false);
    jScrollPane2.setViewportView(ImportFile);

    jLabel2.setText("File Type:");

    FileType.setEnabled(false);

    jLabel3.setText("File Size:");

    FileSize.setEnabled(false);

    ProgressBar.setIndeterminate(true);

    javax.swing.GroupLayout ImportScanScreenLayout = new javax.swing.GroupLayout(
            ImportScanScreen.getContentPane());
    ImportScanScreen.getContentPane().setLayout(ImportScanScreenLayout);
    ImportScanScreenLayout
            .setHorizontalGroup(
                    ImportScanScreenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(ImportScanScreenLayout.createSequentialGroup().addGap(10, 10, 10)
                                    .addGroup(ImportScanScreenLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel1)
                                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    330, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel2)
                                            .addComponent(FileType, javax.swing.GroupLayout.PREFERRED_SIZE, 330,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel3)
                                            .addComponent(FileSize, javax.swing.GroupLayout.PREFERRED_SIZE, 330,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(ProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    330, javax.swing.GroupLayout.PREFERRED_SIZE))));
    ImportScanScreenLayout.setVerticalGroup(ImportScanScreenLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ImportScanScreenLayout.createSequentialGroup().addGap(10, 10, 10).addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 24,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel2)
                    .addGap(6, 6, 6)
                    .addComponent(FileType, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, 0).addComponent(jLabel3).addGap(6, 6, 6)
                    .addComponent(FileSize, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(10, 10, 10).addComponent(ProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));

    MergeButton.setText("Merge");
    MergeButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            MergeButtonActionPerformed(evt);
        }
    });
    VulnTreeContextMenu.add(MergeButton);

    LookupCVE.setText("Lookup CVE(s)");
    LookupCVE.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            LookupCVEActionPerformed(evt);
        }
    });
    VulnTreeContextMenu.add(LookupCVE);

    AddToPersonalVulns.setText("Add to Personal Vulns");
    AddToPersonalVulns.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            AddToPersonalVulnsActionPerformed(evt);
        }
    });
    VulnTreeContextMenu.add(AddToPersonalVulns);

    ClearHash.setText("Clear Hash(s)");
    ClearHash.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ClearHashActionPerformed(evt);
        }
    });
    VulnTreeContextMenu.add(ClearHash);
    VulnTreeContextMenu.add(jSeparator1);

    DeleteButton.setText("Delete");
    DeleteButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            DeleteButtonActionPerformed(evt);
        }
    });
    VulnTreeContextMenu.add(DeleteButton);

    VulnAffectedHostsContextMenu.setMinimumSize(new java.awt.Dimension(20, 20));

    AddHostsButton.setText("Add Host");
    AddHostsButton.setActionCommand("AddHost");
    AddHostsButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            AddHostsButtonActionPerformed(evt);
        }
    });
    VulnAffectedHostsContextMenu.add(AddHostsButton);

    EditHostname.setText("Edit Hostname");
    EditHostname.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            EditHostnameActionPerformed(evt);
        }
    });
    VulnAffectedHostsContextMenu.add(EditHostname);
    VulnAffectedHostsContextMenu.add(jSeparator2);

    DeleteHost.setText("Delete Host ('del' is hotkey)");
    DeleteHost.setActionCommand("DeleteHost");
    DeleteHost.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            DeleteHostActionPerformed(evt);
        }
    });
    VulnAffectedHostsContextMenu.add(DeleteHost);

    InsertReference.setText("Insert Reference");
    InsertReference.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            InsertReferenceActionPerformed(evt);
        }
    });
    VulnReferencesContextMenu.add(InsertReference);

    EditReferenceOption.setText("Edit Reference");
    EditReferenceOption.setToolTipText("");
    EditReferenceOption.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            EditReferenceOptionActionPerformed(evt);
        }
    });
    VulnReferencesContextMenu.add(EditReferenceOption);

    LaunchInBrowser.setText("Launch in Browser");
    LaunchInBrowser.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            LaunchInBrowserActionPerformed(evt);
        }
    });
    VulnReferencesContextMenu.add(LaunchInBrowser);
    VulnReferencesContextMenu.add(jSeparator3);

    DeleteReferenceOption.setText("Delete Reference");
    DeleteReferenceOption.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            DeleteReferenceOptionActionPerformed(evt);
        }
    });
    VulnReferencesContextMenu.add(DeleteReferenceOption);

    ManageAffectedHosts.setTitle("Report Compiler - Manage Affected Hosts");
    ManageAffectedHosts.addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowOpened(java.awt.event.WindowEvent evt) {
            ManageAffectedHostsWindowOpened(evt);
        }
    });

    jScrollPane5.setViewportView(ListOfHosts);

    jScrollPane9.setViewportView(ListOfOpenPorts);

    jLabel5.setText("Hosts");

    jLabel13.setText("Ports");

    javax.swing.GroupLayout ManageAffectedHostsLayout = new javax.swing.GroupLayout(
            ManageAffectedHosts.getContentPane());
    ManageAffectedHosts.getContentPane().setLayout(ManageAffectedHostsLayout);
    ManageAffectedHostsLayout.setHorizontalGroup(
            ManageAffectedHostsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ManageAffectedHostsLayout.createSequentialGroup().addGap(25, 25, 25)
                            .addGroup(ManageAffectedHostsLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 180,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel5))
                            .addGap(18, 18, 18)
                            .addGroup(ManageAffectedHostsLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel13).addComponent(jScrollPane9,
                                            javax.swing.GroupLayout.PREFERRED_SIZE, 213,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    ManageAffectedHostsLayout.setVerticalGroup(
            ManageAffectedHostsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(ManageAffectedHostsLayout.createSequentialGroup().addContainerGap()
                            .addGroup(ManageAffectedHostsLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel5).addComponent(jLabel13))
                            .addGap(13, 13, 13)
                            .addGroup(ManageAffectedHostsLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 291,
                                            Short.MAX_VALUE)
                                    .addComponent(jScrollPane9))
                            .addContainerGap(36, Short.MAX_VALUE)));

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Report Compiler - Main Window");
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });

    jLabel20.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLabel20.setText("Tree Filter:");

    VulnTreeFilter.addCaretListener(new javax.swing.event.CaretListener() {
        public void caretUpdate(javax.swing.event.CaretEvent evt) {
            VulnTreeFilterCaretUpdate(evt);
        }
    });

    ExtraInfoLabel.setFont(
            ExtraInfoLabel.getFont().deriveFont(ExtraInfoLabel.getFont().getStyle() | java.awt.Font.BOLD));
    ExtraInfoLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);

    javax.swing.GroupLayout MainScreenBottomPanelLayout = new javax.swing.GroupLayout(MainScreenBottomPanel);
    MainScreenBottomPanel.setLayout(MainScreenBottomPanelLayout);
    MainScreenBottomPanelLayout.setHorizontalGroup(MainScreenBottomPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MainScreenBottomPanelLayout.createSequentialGroup().addContainerGap()
                    .addComponent(jLabel20)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(VulnTreeFilter, javax.swing.GroupLayout.PREFERRED_SIZE, 174,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 354, Short.MAX_VALUE)
                    .addComponent(ExtraInfoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 556,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    MainScreenBottomPanelLayout.setVerticalGroup(MainScreenBottomPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MainScreenBottomPanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(MainScreenBottomPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(MainScreenBottomPanelLayout.createSequentialGroup()
                                    .addComponent(ExtraInfoLabel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addGap(20, 20, 20))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                    MainScreenBottomPanelLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jLabel20).addComponent(VulnTreeFilter,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    getContentPane().add(MainScreenBottomPanel, java.awt.BorderLayout.SOUTH);

    jSplitPane2.setDividerLocation(200);
    jSplitPane2.setDividerSize(20);
    jSplitPane2.setOneTouchExpandable(true);

    ViewModeTabPane.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            ViewModeTabPaneStateChanged(evt);
        }
    });

    javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode(
            "NOT IMPLEMENTED");
    VulnTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
    VulnTree.setCellRenderer(new VulnerabilityViewTreeCellRenderer(true));
    VulnTree.setRootVisible(false);
    VulnTree.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            VulnTreeMouseClicked(evt);
        }
    });
    VulnTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
        public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
            VulnTreeValueChanged(evt);
        }
    });
    VulnTree.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            VulnTreeKeyPressed(evt);
        }
    });
    jScrollPane1.setViewportView(VulnTree);

    ViewModeTabPane.addTab("Vuln View", jScrollPane1);

    jScrollPane3.setEnabled(false);

    treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root");
    HostTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
    HostTree.setRootVisible(false);
    jScrollPane3.setViewportView(HostTree);

    ViewModeTabPane.addTab("Host View", jScrollPane3);

    jSplitPane2.setLeftComponent(ViewModeTabPane);

    RightPanelCardLayout.setLayout(new java.awt.CardLayout());

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

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

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

    jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
    jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    jLabel9.setLabelFor(VulnTitleTextField);
    jLabel9.setText("Title: ");
    jPanel8.add(jLabel9);

    VulnTitleTextField.setColumns(80);
    jPanel8.add(VulnTitleTextField);

    VulnerabilityTopPanel.add(jPanel8, java.awt.BorderLayout.NORTH);

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

    jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
    jLabel10.setText("CVSS:");
    jPanel9.add(jLabel10);

    VulnCVSSVectorTextField.setEditable(false);
    VulnCVSSVectorTextField.setColumns(81);
    jPanel9.add(VulnCVSSVectorTextField);

    jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
    jLabel11.setText("Category:");
    jPanel9.add(jLabel11);

    VulnRiskCategory.setEditable(false);
    VulnRiskCategory.setColumns(8);
    jPanel9.add(VulnRiskCategory);

    jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
    jLabel12.setText("Score:");
    jPanel9.add(jLabel12);

    VulnScore.setEditable(false);
    VulnScore.setColumns(4);
    jPanel9.add(VulnScore);

    EditRiskButton.setText("Edit Risk");
    EditRiskButton.setToolTipText("Click here to see the Risk Calculator where scores can be modified");
    EditRiskButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            EditRiskButtonActionPerformed(evt);
        }
    });
    jPanel9.add(EditRiskButton);

    VulnerabilityTopPanel.add(jPanel9, java.awt.BorderLayout.CENTER);

    RightPanelVulnView.add(VulnerabilityTopPanel, java.awt.BorderLayout.NORTH);

    jSplitPane1.setDividerLocation(200);
    jSplitPane1.setDividerSize(20);
    jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    jSplitPane1.setOneTouchExpandable(true);

    jSplitPane3.setDividerLocation(200);
    jSplitPane3.setDividerSize(20);
    jSplitPane3.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    jSplitPane3.setOneTouchExpandable(true);

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

    jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLabel8.setText("Recommendation");
    VulnRecommendationsPanel.add(jLabel8, java.awt.BorderLayout.PAGE_START);

    jScrollPane7.setViewportView(VulnRecommendationTextPane);

    VulnRecommendationsPanel.add(jScrollPane7, java.awt.BorderLayout.CENTER);

    jSplitPane3.setLeftComponent(VulnRecommendationsPanel);

    jSplitPane4.setDividerSize(20);
    jSplitPane4.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    jSplitPane4.setOneTouchExpandable(true);

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

    jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLabel4.setText("Affected Hosts");
    VulnReferencesPanel.add(jLabel4, java.awt.BorderLayout.PAGE_END);

    jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLabel7.setText("References");
    VulnReferencesPanel.add(jLabel7, java.awt.BorderLayout.PAGE_START);

    VulnReferencesList.setModel(new DefaultListModel());
    VulnReferencesList.setToolTipText("Right click on this area to see options for references.");
    VulnReferencesList.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            VulnReferencesListMouseClicked(evt);
        }
    });
    VulnReferencesList.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            VulnReferencesListKeyPressed(evt);
        }
    });
    jScrollPane6.setViewportView(VulnReferencesList);

    VulnReferencesPanel.add(jScrollPane6, java.awt.BorderLayout.CENTER);

    jSplitPane4.setTopComponent(VulnReferencesPanel);

    jScrollPane4.setToolTipText(
            "Right click on this area to insert new affected hosts. Select one or more and press 'del' to delete or use the right click 'delete' option.");
    jScrollPane4.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jScrollPane4MouseClicked(evt);
        }
    });
    jScrollPane4.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            jScrollPane4KeyPressed(evt);
        }
    });

    VulnAffectedHostsTable.setAutoCreateRowSorter(true);
    VulnAffectedHostsTable.setModel(new AffectedHostsTableModel());

    /*new javax.swing.table.DefaultTableModel(
    new Object[][]{},
    new String[]{
        "IP Address", "Hostname", "Portnumber", "Protocol"
    }
    ) {
    Class[] types = new Class[]{
        Host.class, java.lang.String.class, java.lang.Integer.class, java.lang.String.class
    };
            
    public Class getColumnClass(int columnIndex) {
        return types[columnIndex];
    }
    }*///);
    VulnAffectedHostsTable.setToolTipText("");
    VulnAffectedHostsTable.setCellSelectionEnabled(true);
    VulnAffectedHostsTable.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            VulnAffectedHostsTableMouseClicked(evt);
        }
    });
    VulnAffectedHostsTable.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            VulnAffectedHostsTableKeyPressed(evt);
        }
    });
    jScrollPane4.setViewportView(VulnAffectedHostsTable);
    VulnAffectedHostsTable.getColumnModel().getSelectionModel()
            .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    jSplitPane4.setRightComponent(jScrollPane4);

    jSplitPane3.setRightComponent(jSplitPane4);

    jSplitPane1.setBottomComponent(jSplitPane3);

    VulnDescriptionPanel.setMinimumSize(new java.awt.Dimension(0, 50));
    VulnDescriptionPanel.setLayout(new java.awt.BorderLayout());

    jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
    jLabel6.setText("Description");
    VulnDescriptionPanel.add(jLabel6, java.awt.BorderLayout.PAGE_START);

    jScrollPane8.setViewportView(VulnDescriptionTextPane);

    VulnDescriptionPanel.add(jScrollPane8, java.awt.BorderLayout.CENTER);

    jSplitPane1.setTopComponent(VulnDescriptionPanel);

    RightPanelVulnView.add(jSplitPane1, java.awt.BorderLayout.CENTER);

    RightPanelCardLayout.add(RightPanelVulnView, "vulnView");

    javax.swing.GroupLayout RightPanelHostsViewLayout = new javax.swing.GroupLayout(RightPanelHostsView);
    RightPanelHostsView.setLayout(RightPanelHostsViewLayout);
    RightPanelHostsViewLayout.setHorizontalGroup(RightPanelHostsViewLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 1103, Short.MAX_VALUE));
    RightPanelHostsViewLayout.setVerticalGroup(RightPanelHostsViewLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 739, Short.MAX_VALUE));

    RightPanelCardLayout.add(RightPanelHostsView, "hostView");

    jSplitPane2.setRightComponent(RightPanelCardLayout);

    getContentPane().add(jSplitPane2, java.awt.BorderLayout.CENTER);

    jMenu1.setMnemonic('F');
    jMenu1.setText("File");

    jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N,
            java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem3.setText("New (Clear Tree)");
    jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem3ActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItem3);

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

    jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
            java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem5.setText("Save");
    jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem5ActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItem5);

    jMenuItem11.setText("Save As");
    jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem11ActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItem11);

    exitButton.setText("Exit");
    exitButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitButtonActionPerformed(evt);
        }
    });
    jMenu1.add(exitButton);

    jMenuBar1.add(jMenu1);

    jMenu2.setMnemonic('V');
    jMenu2.setText("Vulnerabilities");
    jMenu2.setToolTipText(
            "All vulnerability related operations. Import from a tool, create an entirely new one etc");

    jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem1.setText("Import from Tool");
    jMenuItem1.setToolTipText("Select one or more files to import simultaneously. ");
    jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem1ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem1);

    jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_INSERT,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem2.setText("Create New Vulnerability");
    jMenuItem2.setToolTipText(
            "Add a new vulnerability to your test. When finished you can save it to your Personal Vulnerability database by right clicking on the issue in the tree");
    jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem2ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem2);

    jMenuItem7.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem7.setText("Manage Personal Vulns");
    jMenuItem7.setToolTipText(
            "Allows you to delete or edit the text for vulnerabilities in your Personal Database");
    jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem7ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem7);

    jMenuItem10.setText("Auto Merge");
    jMenuItem10.setToolTipText(
            "Use this to automatically replace the title, description, recommendation, references, and risk score with vulnerabilities in your personal database.");
    jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem10ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem10);

    jMenuBar1.add(jMenu2);

    jMenu4.setText("Hosts");

    jMenuItem9.setText("Import Hosts by Nmap");
    jMenuItem9.setEnabled(false);
    jMenu4.add(jMenuItem9);

    jMenuBar1.add(jMenu4);

    jMenu3.setMnemonic('E');
    jMenu3.setText("Export");

    jMenuItem8.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem8.setText("Excel Vulnerability List");
    jMenuItem8.setToolTipText(
            "This can be used to send a high level debrief to clients in a spreadsheet format. Report Compiler also imports vulnerabilities back from these excel files if necessary.");
    jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem8ActionPerformed(evt);
        }
    });
    jMenu3.add(jMenuItem8);

    jMenuBar1.add(jMenu3);

    jMenu5.setText("Options");

    increaseFont.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_EQUALS,
            java.awt.event.InputEvent.CTRL_MASK));
    increaseFont.setText("Increase Font");
    increaseFont.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            increaseFontActionPerformed(evt);
        }
    });
    jMenu5.add(increaseFont);

    decreaseFont.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_MINUS,
            java.awt.event.InputEvent.CTRL_MASK));
    decreaseFont.setText("Decrease Font");
    decreaseFont.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            decreaseFontActionPerformed(evt);
        }
    });
    jMenu5.add(decreaseFont);

    jMenuBar1.add(jMenu5);

    setJMenuBar(jMenuBar1);

    pack();
    setLocationRelativeTo(null);
}

From source file:corelyzer.ui.CorelyzerApp.java

private JPopupMenu sectionListPopupMenu(final int[] rows) {
    // section popup
    JPopupMenu menu = new JPopupMenu("Sections");

    // Section/Image property
    JMenuItem propertiesMenuItem = new JMenuItem("Properties...");
    propertiesMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, MENU_MASK));
    propertiesMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            controller.sectionProperties(rows);
        }/*from   w ww  .j a  v a  2 s.co m*/
    });

    JMenuItem splitMenuItem = new JMenuItem("Split...");
    if (rows.length > 1) {
        splitMenuItem.setEnabled(false);
    }
    splitMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            controller.sectionSplit();
        }
    });

    JMenuItem deleteMenuItem = new JMenuItem("Delete");
    deleteMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            onDeleteSelectedSections(rows);
        }
    });

    JMenuItem locateMenuItem = new JMenuItem("Locate");
    locateMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            onLocateSelectedSection();
        }
    });

    menu.add(locateMenuItem);
    menu.add(splitMenuItem);
    menu.add(propertiesMenuItem);
    menu.add(deleteMenuItem);

    return menu;
}

From source file:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java

/**
 * Initialize the contents of the frame.
 * //from  ww  w  .  ja v  a  2 s . c  o  m
 * @throws ClassNotFoundException
 * @throws SQLException
 */
private void initializeGUI() throws SQLException, ClassNotFoundException {
    frmMainWindow = new JFrame();
    frmMainWindow.setFont(new Font("Arial", Font.PLAIN, 12));
    frmMainWindow.setSize(new Dimension(810, 600));
    frmMainWindow.setResizable(false);
    frmMainWindow.setIconImage(Toolkit.getDefaultToolkit()
            .getImage(MainCommGUI.class.getResource("/de/dmarcini/submatix/pclogger/res/112.png")));
    frmMainWindow.setTitle(LangStrings.getString("MainCommGUI.frmMainWindow.title")); //$NON-NLS-1$
    frmMainWindow.setBounds(100, 100, 800, 600);
    frmMainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmMainWindow.getContentPane().setLayout(new BorderLayout(0, 0));
    frmMainWindow.addWindowListener(new MainWindowListener());
    statusTextField = new JTextField();
    statusTextField.setEditable(false);
    statusTextField.setText("-");
    frmMainWindow.getContentPane().add(statusTextField, BorderLayout.SOUTH);
    statusTextField.setColumns(10);
    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    frmMainWindow.getContentPane().add(tabbedPane, BorderLayout.CENTER);
    tabbedPane.addMouseMotionListener(this);
    // Connection Panel
    connectionPanel = new spx42ConnectPanel(databaseUtil);
    tabbedPane.addTab("CONNECTION", null, connectionPanel, null);
    tabbedPane.setEnabledAt(programTabs.TAB_CONNECT.ordinal(), true);
    // config Panel
    configPanel = new spx42ConfigPanel();
    tabbedPane.addTab("CONFIG", null, configPanel, null);
    tabbedPane.setEnabledAt(programTabs.TAB_CONFIG.ordinal(), true);
    // GASPANEL
    gasConfigPanel = new spx42GaslistEditPanel(databaseUtil);
    tabbedPane.addTab("GAS", null, gasConfigPanel, null);
    tabbedPane.setEnabledAt(programTabs.TAB_GASLIST.ordinal(), true);
    // Loglisten Panel
    logListPanel = new spx42LoglistPanel(this, databaseUtil);
    tabbedPane.addTab("LOG", null, logListPanel, null);
    tabbedPane.setEnabledAt(programTabs.TAB_LOGREAD.ordinal(), true);
    // Grafik Panel
    logGraphPanel = new spx42LogGraphPanel(databaseUtil);
    tabbedPane.addTab("GRAPH", null, logGraphPanel, null);
    tabbedPane.setEnabledAt(programTabs.TAB_LOGGRAPH.ordinal(), true);
    // import/export Panel
    fileManagerPanel = new spx42FileManagerPanel(this, databaseUtil);
    tabbedPane.addTab("EXPORT", null, fileManagerPanel, null);
    tabbedPane.setEnabledAt(programTabs.TAB_FILEMANAGER.ordinal(), true);
    // MEN
    JMenuBar menuBar = new JMenuBar();
    frmMainWindow.setJMenuBar(menuBar);
    mnFile = new JMenu(LangStrings.getString("MainCommGUI.mnFile.text")); //$NON-NLS-1$
    menuBar.add(mnFile);
    mntmExit = new JMenuItem(LangStrings.getString("MainCommGUI.mntmExit.text")); //$NON-NLS-1$
    mntmExit.setIcon(
            new ImageIcon(MainCommGUI.class.getResource("/de/dmarcini/submatix/pclogger/res/176.png")));
    mntmExit.setActionCommand("exit");
    mntmExit.addActionListener(this);
    mntmExit.addMouseMotionListener(this);
    mntmExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK));
    mnFile.add(mntmExit);
    mnLanguages = new JMenu(LangStrings.getString("MainCommGUI.mnLanguages.text")); //$NON-NLS-1$
    mnLanguages.addMouseMotionListener(this);
    menuBar.add(mnLanguages);
    mnOptions = new JMenu(LangStrings.getString("MainCommGUI.mnOptions.text")); //$NON-NLS-1$
    mnOptions.addMouseMotionListener(this);
    menuBar.add(mnOptions);
    mntmOptions = new JMenuItem(LangStrings.getString("MainCommGUI.mntmOptions.text")); //$NON-NLS-1$
    mntmOptions.addMouseMotionListener(this);
    mntmOptions.addActionListener(this);
    mntmOptions.setActionCommand("set_propertys");
    mnOptions.add(mntmOptions);
    mnHelp = new JMenu(LangStrings.getString("MainCommGUI.mnHelp.text")); //$NON-NLS-1$
    mnHelp.addMouseMotionListener(this);
    menuBar.add(mnHelp);
    mntmHelp = new JMenuItem(LangStrings.getString("MainCommGUI.mntmHelp.text")); //$NON-NLS-1$
    mntmHelp.addActionListener(this);
    mntmHelp.setActionCommand("help");
    mntmHelp.addMouseMotionListener(this);
    mnHelp.add(mntmHelp);
    mntmInfo = new JMenuItem(LangStrings.getString("MainCommGUI.mntmInfo.text")); //$NON-NLS-1$
    mntmInfo.addActionListener(this);
    mntmInfo.setActionCommand("info");
    mntmInfo.addMouseMotionListener(this);
    mntmInfo.setIcon(
            new ImageIcon(MainCommGUI.class.getResource("/javax/swing/plaf/metal/icons/ocean/expanded.gif")));
    mntmInfo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_MASK));
    mnHelp.add(mntmInfo);
}

From source file:corelyzer.ui.CorelyzerApp.java

private void setupMenuStuff() {
    menuBar = new JMenuBar();

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

    JMenuItem createSessionMenuItem = new JMenuItem("Create a Session", KeyEvent.VK_N);
    createSessionMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, MENU_MASK));
    createSessionMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.createSession();// w  w  w.jav  a2  s .  c om
        }
    });
    createSessionMenuItem.setEnabled(true);
    fileMenu.add(createSessionMenuItem);

    createTrackMenuItem = new JMenuItem("Create a Track", KeyEvent.VK_T);
    createTrackMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, MENU_MASK));
    createTrackMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.createTrack();
        }
    });
    createTrackMenuItem.setEnabled(false);
    fileMenu.add(createTrackMenuItem);

    fileMenu.addSeparator();

    // Images
    JMenu loadImageMenu = new JMenu("Load Images");
    loadImageMenuItem = new JMenuItem("Open Local Image Files...", KeyEvent.VK_M);
    loadImageMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, MENU_MASK));
    loadImageMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.loadImageAction();
        }
    });
    loadImageMenu.add(loadImageMenuItem);

    // "Auto-load" 4/25/2012 brg
    JMenuItem autoLoadImageMenuItem = new JMenuItem("Open Image Listing...");
    autoLoadImageMenuItem.setEnabled(true);
    autoLoadImageMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.loadImageListingAction();
        }
    });
    loadImageMenu.add(autoLoadImageMenuItem);

    // online image services
    JMenuItem chronosMenuItem = new JMenuItem("Online Image Services...");
    loadImageMenu.add(chronosMenuItem);
    chronosMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            IODPListsDialog d = new IODPListsDialog(getMainFrame());
            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisibleTab(1);
            d.setVisible(true);
        }
    });

    fileMenu.add(loadImageMenu);

    // Numbercal data (plots)
    JMenu loadDataMenu = new JMenu("Load Data");

    loadDataMenuItem = new JMenuItem("Open Local Dataset Files", KeyEvent.VK_D);
    loadDataMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, MENU_MASK));
    loadDataMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            Runnable r = new Runnable() {
                public void run() {
                    controller.loadData();
                }
            };

            new Thread(r).start();
        }
    });
    loadDataMenu.add(loadDataMenuItem);
    fileMenu.add(loadDataMenu);

    JMenuItem quickDataImportMenuItem = new JMenuItem("Quick Data Import...");
    quickDataImportMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.quickDataImport();
        }
    });
    loadDataMenu.add(quickDataImportMenuItem);

    JMenuItem importDataMenuItem = new JMenuItem("Custom Data Import...");
    importDataMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.importData();
        }
    });
    loadDataMenu.add(importDataMenuItem);

    // LoggingDB
    JMenuItem loggingDBMenuItem = new JMenuItem("LDEO logging DB...");
    loggingDBMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            IODPListsDialog d = new IODPListsDialog(getMainFrame());
            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisibleTab(2);
            d.setVisible(true);
        }
    });
    loadDataMenu.add(loggingDBMenuItem);

    fileMenu.addSeparator();

    loadStateFileMenuItem = new JMenuItem("Open a Session File", KeyEvent.VK_O);
    loadStateFileMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, MENU_MASK));
    loadStateFileMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.loadStateFile();
        }
    });
    loadStateFileMenuItem.setEnabled(false);
    fileMenu.add(loadStateFileMenuItem);

    JMenuItem saveMenuItem = new JMenuItem("Save Session", KeyEvent.VK_S);
    saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MENU_MASK));
    saveMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            controller.saveCurrentSession();
        }
    });
    fileMenu.add(saveMenuItem);

    JMenuItem saveStateToFileMenuItem = new JMenuItem("Save Session As...", KeyEvent.VK_S);
    saveStateToFileMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, MENU_MASK));
    saveStateToFileMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.saveStateToFile();
        }
    });
    fileMenu.add(saveStateToFileMenuItem);

    // Session History
    recentSessionsMenu = new JMenu("Recent Sessions");
    controller.refreshSessionHistoryMenu();
    fileMenu.add(recentSessionsMenu);

    fileMenu.addSeparator();

    JMenu packageMenu = new JMenu("Core Archive");
    JMenuItem importMenuItem = new JMenuItem("Import...");
    importMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.importPackage();
        }
    });
    packageMenu.add(importMenuItem);

    JMenuItem exportMenuItem = new JMenuItem("Export...");
    exportMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.exportTheWholeScene();
        }
    });
    packageMenu.add(exportMenuItem);
    fileMenu.add(packageMenu);

    JMenu limsMenu = new JMenu("IODP");

    JMenuItem allIODPLists = new JMenuItem("All IODP lists...");
    allIODPLists.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            IODPListsDialog d = new IODPListsDialog(getMainFrame());
            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisible(true);
        }
    });
    limsMenu.add(allIODPLists);

    JMenuItem loadLIMSTables = new JMenuItem("Load a section list...");
    loadLIMSTables.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            IODPListsDialog d = new IODPListsDialog(getMainFrame());
            d.loadLIMSTables(getMainFrame());

            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisibleTab(0);
            d.setVisible(true);
        }
    });
    limsMenu.add(loadLIMSTables);

    JMenuItem loadAffineTable = new JMenuItem("Load an affine table...");
    loadAffineTable.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            IODPListsDialog d = new IODPListsDialog(getMainFrame());
            d.loadAAffineTable(getMainFrame());

            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisibleTab(3);
            d.setVisible(true);
        }
    });
    limsMenu.add(loadAffineTable);

    JMenuItem loadSpliceTable = new JMenuItem("Load a splice table...");
    loadSpliceTable.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            IODPListsDialog d = new IODPListsDialog(getMainFrame());
            d.loadASpliceTable(getMainFrame());

            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisibleTab(4);
            d.setVisible(true);
        }
    });
    limsMenu.add(loadSpliceTable);

    fileMenu.add(limsMenu);

    JMenu disMenu = new JMenu("DIS");

    JMenuItem disListMenuItem = new JMenuItem("Accessing DIS...");
    disListMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            DISListsDialog d = new DISListsDialog(getMainFrame());
            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisible(true);
        }
    });

    JMenuItem disImport = new JMenuItem("Import...");
    disImport.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.disImport();
        }
    });
    JMenuItem disExport = new JMenuItem("Export...");
    disExport.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.disExport();
        }
    });

    JMenuItem disBatchDataLoad = new JMenuItem("Load Tab Delimited Data File...");
    disBatchDataLoad.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.disBatchDataLoad();
        }
    });

    disMenu.add(disListMenuItem);
    disMenu.add(disImport);
    disMenu.add(disExport);
    disMenu.add(disBatchDataLoad);
    fileMenu.add(disMenu);

    JMenuItem saveOutputToFileMenuItem = new JMenuItem("Export Sheets...", KeyEvent.VK_A);
    saveOutputToFileMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.saveOutputToFile();
        }
    });
    fileMenu.add(saveOutputToFileMenuItem);

    fileMenu.addSeparator();

    JMenuItem quitMenuItem = new JMenuItem("Quit");
    fileMenu.add(quitMenuItem);
    quitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, MENU_MASK));
    quitMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.quit();
        }
    });

    menuBar.add(fileMenu);

    // Create Edit Menu
    JMenu editMenu = new JMenu("Edit");
    editMenu.setMnemonic(KeyEvent.VK_E);

    JMenuItem clearImageCacheMenuItem = new JMenuItem("Clear Image Cache...", KeyEvent.VK_I);
    clearImageCacheMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.clearImageCache();
        }
    });
    editMenu.add(clearImageCacheMenuItem);

    editMenu.addSeparator();
    JMenuItem depthDirection = new JMenuItem("Switch Depth Direction", KeyEvent.VK_K);
    depthDirection.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, MENU_MASK));
    depthDirection.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            boolean b = SceneGraph.getDepthOrientation();
            SceneGraph.setDepthOrientation(!b);

            CorelyzerApp.getApp().updateGLWindows();
        }
    });
    editMenu.add(depthDirection);

    JMenuItem tour = new JMenuItem("Tour...");
    tour.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            CRNavigationSetupDialog dlg = new CRNavigationSetupDialog();
            dlg.pack();
            dlg.setLocationRelativeTo(getApp().getMainFrame());

            dlg.setAlwaysOnTop(true);
            dlg.setVisible(true);
        }
    });

    editMenu.add(tour);

    editMenu.addSeparator();
    JMenuItem preferencesMenuItem = new JMenuItem("Preferences...");
    editMenu.add(preferencesMenuItem);
    preferencesMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.doPreferences();
        }
    });

    menuBar.add(editMenu);

    // Create Share Menu
    JMenu shareMenu = new JMenu("Share");

    JMenuItem publishMenuItem = new JMenuItem("Publish...");
    publishMenuItem.setEnabled(true);
    publishMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            controller.publishASession();
        }
    });
    shareMenu.add(publishMenuItem);

    JMenuItem listMenuItem = new JMenuItem("List...");
    listMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            controller.listSessions();
        }
    });
    shareMenu.add(listMenuItem);

    shareMenu.addSeparator();

    friendsMenu = new JMenu("Friends");
    shareMenu.add(friendsMenu);

    menuBar.add(shareMenu);

    // Create Debug Menu
    JMenu debugMenu = new JMenu("Debug");
    debugMenu.setMnemonic(KeyEvent.VK_D);

    JMenuItem matchTestMenuItem = new JMenuItem("Match-Test", KeyEvent.VK_B);
    matchTestMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            controller.testAndMatch();
        }
    });

    debugMenu.add(matchTestMenuItem);

    if ((System.getenv("DEBUG") != null) && System.getenv("DEBUG").equals("YES")) {
        menuBar.add(shareMenu);
    }

    // Create the Plugin Menu
    pluginMenu = new JMenu("Plugins");
    menuBar.add(pluginMenu);
    pluginMenuItemVec = new Vector<JMenuItem>();

    // Lists
    JMenu listsMenu = new JMenu("Lists");

    JMenuItem iodpLists = new JMenuItem("IODP lists...");
    iodpLists.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            IODPListsDialog d = new IODPListsDialog(getMainFrame());
            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisible(true);
        }
    });
    listsMenu.add(iodpLists);

    JMenuItem disLists = new JMenuItem("DIS lists...");
    disLists.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            DISListsDialog d = new DISListsDialog(getMainFrame());
            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisible(true);
        }
    });
    listsMenu.add(disLists);

    JMenu annotLists = new JMenu("Annotation");

    JMenuItem freeformsItem = new JMenuItem("Default");
    freeformsItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            FreeformAnnotationListDialog dlg = new FreeformAnnotationListDialog(getApp().getMainFrame());
            dlg.pack();
            dlg.setLocationRelativeTo(getApp().getMainFrame());
            dlg.onRefresh();

            dlg.setAlwaysOnTop(true);
            dlg.setVisible(true);
        }
    });
    annotLists.add(freeformsItem);

    JMenuItem clastListItem = new JMenuItem("Clast");
    clastListItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            ClastStatisticsDialog dlg = new ClastStatisticsDialog(getApp().getMainFrame());
            dlg.pack();
            dlg.setLocationRelativeTo(getApp().getMainFrame());
            dlg.onRefresh();

            dlg.setAlwaysOnTop(true);
            dlg.setVisible(true);
        }
    });
    annotLists.add(clastListItem);

    JMenuItem sampleReqsItem = new JMenuItem("Sample");
    sampleReqsItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            SampleRequestListDialog dlg = new SampleRequestListDialog(getApp().getMainFrame());
            dlg.pack();
            dlg.setLocationRelativeTo(getApp().getMainFrame());
            dlg.onRefresh();

            dlg.setAlwaysOnTop(true);
            dlg.setVisible(true);
        }
    });
    annotLists.add(sampleReqsItem);
    listsMenu.add(annotLists);

    menuBar.add(listsMenu);

    // Create Tools Menu
    JMenu toolsMenu = new JMenu("Tools");
    JMenuItem wholeCoreViewerMenuItem = new JMenuItem("Get 3D Whole Core Imagery Viewer...");
    wholeCoreViewerMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            try {
                String app;
                String url = "http://www.evl.uic.edu/cavern/corewall/SciVizCore/";

                if (System.getProperty("os.name").toLowerCase().contains("windows")) {
                    app = "cmd.exe /c explorer " + url;
                    Runtime.getRuntime().exec(app);
                } else {
                    app = "open";
                    String[] cmd = { app, url };
                    Runtime.getRuntime().exec(cmd);
                }
            } catch (IOException ex) {
                System.err.println("IOException in opening SciVizCore link");
            }
        }
    });

    toolsMenu.add(wholeCoreViewerMenuItem);

    // DEBUG
    String debug = System.getProperty("DEBUG");
    if ((debug != null) && System.getProperty("DEBUG").equals("true")) {
        JMenuItem gcItem = new JMenuItem("GC");
        gcItem.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                long mem0 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
                System.out.println("- B4 mem:\t" + mem0 / 1000000.0f);

                int trials = 10000;
                for (int i = 0; i < trials; i++) {
                    updateGLWindows();
                }

                long mem1 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
                System.out.println("- " + trials + " mem:\t" + mem1 / 1000000.0f);

                System.gc();
                System.gc();
                System.gc();

                long mem2 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
                System.out.println("- AferGC mem:\t" + mem2 / 1000000.0f);
            }
        });
        toolsMenu.add(gcItem);
    }

    menuBar.add(toolsMenu);

    // Create Help Menu
    // Create JavaHelp hooks
    File helpSet = new File("help/jhelpset.hs");
    HelpSet hs = null;
    try {
        URL hsURL = helpSet.toURI().toURL();
        hs = new HelpSet(null, hsURL);
    } catch (HelpSetException e) {
        JOptionPane.showMessageDialog(getMainFrame(), "Cannot find help: format error.");
        e.printStackTrace();
    } catch (MalformedURLException e) {
        JOptionPane.showMessageDialog(getMainFrame(), "Cannot find help: malformed URL.");
        e.printStackTrace();
    }

    // Help UI
    JMenu helpMenu = new JMenu("Help");
    JMenuItem helpMenuItem = new JMenuItem("Help", KeyEvent.VK_H);

    if (hs != null) {
        HelpBroker hb = hs.createHelpBroker();
        helpActionListener = new CSH.DisplayHelpFromSource(hb);
        helpMenuItem.addActionListener(helpActionListener);
    } else {
        helpMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                controller.helpAction();
            }
        });
    }
    helpMenu.add(helpMenuItem);

    helpMenu.addSeparator();
    JMenuItem aboutMenuItem = new JMenuItem("About Corelyzer");
    helpMenu.add(aboutMenuItem);
    aboutMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.about();
        }
    });

    menuBar.add(helpMenu);

    mainFrame.setJMenuBar(menuBar);
}

From source file:org.forester.archaeopteryx.TreePanel.java

final private void keyPressedCalls(final KeyEvent e) {
    if (isOvOn() && (getMousePosition() != null) && (getMousePosition().getLocation() != null)) {
        if (inOvVirtualRectangle(getMousePosition().x, getMousePosition().y)) {
            if (!isInOvRect()) {
                setInOvRect(true);/*from  w ww .  j  a v  a  2s.c o m*/
            }
        } else if (isInOvRect()) {
            setInOvRect(false);
        }
    }
    if (e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK) {
        if ((e.getKeyCode() == KeyEvent.VK_DELETE) || (e.getKeyCode() == KeyEvent.VK_HOME)
                || (e.getKeyCode() == KeyEvent.VK_F)) {
            getMainPanel().getTreeFontSet().mediumFonts();
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true);
        } else if ((e.getKeyCode() == KeyEvent.VK_SUBTRACT) || (e.getKeyCode() == KeyEvent.VK_MINUS)) {
            getMainPanel().getTreeFontSet().decreaseFontSize();
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true);
        } else if (plusPressed(e.getKeyCode())) {
            getMainPanel().getTreeFontSet().increaseFontSize();
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true);
        }
    } else {
        if ((e.getKeyCode() == KeyEvent.VK_DELETE) || (e.getKeyCode() == KeyEvent.VK_HOME)
                || (e.getKeyCode() == KeyEvent.VK_F)) {
            getControlPanel().showWhole();
        } else if ((e.getKeyCode() == KeyEvent.VK_UP) || (e.getKeyCode() == KeyEvent.VK_DOWN)
                || (e.getKeyCode() == KeyEvent.VK_LEFT) || (e.getKeyCode() == KeyEvent.VK_RIGHT)) {
            if (e.getModifiersEx() == InputEvent.SHIFT_DOWN_MASK) {
                if (e.getKeyCode() == KeyEvent.VK_UP) {
                    getMainPanel().getControlPanel().zoomInY(Constants.WHEEL_ZOOM_IN_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                    getMainPanel().getControlPanel().zoomOutY(Constants.WHEEL_ZOOM_OUT_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
                    getMainPanel().getControlPanel().zoomOutX(Constants.WHEEL_ZOOM_OUT_FACTOR,
                            Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
                    getMainPanel().getControlPanel().zoomInX(Constants.WHEEL_ZOOM_IN_FACTOR,
                            Constants.WHEEL_ZOOM_IN_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                }
            } else {
                final int d = 80;
                int dx = 0;
                int dy = -d;
                if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                    dy = d;
                } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
                    dx = -d;
                    dy = 0;
                } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
                    dx = d;
                    dy = 0;
                }
                final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport()
                        .getViewPosition();
                scroll_position.x = scroll_position.x + dx;
                scroll_position.y = scroll_position.y + dy;
                if (scroll_position.x <= 0) {
                    scroll_position.x = 0;
                } else {
                    final int max_x = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar()
                            .getMaximum()
                            - getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getVisibleAmount();
                    if (scroll_position.x >= max_x) {
                        scroll_position.x = max_x;
                    }
                }
                if (scroll_position.y <= 0) {
                    scroll_position.y = 0;
                } else {
                    final int max_y = getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getMaximum()
                            - getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getVisibleAmount();
                    if (scroll_position.y >= max_y) {
                        scroll_position.y = max_y;
                    }
                }
                repaint();
                getMainPanel().getCurrentScrollPane().getViewport().setViewPosition(scroll_position);
            }
        } else if ((e.getKeyCode() == KeyEvent.VK_SUBTRACT) || (e.getKeyCode() == KeyEvent.VK_MINUS)) {
            getMainPanel().getControlPanel().zoomOutY(Constants.WHEEL_ZOOM_OUT_FACTOR);
            getMainPanel().getControlPanel().zoomOutX(Constants.WHEEL_ZOOM_OUT_FACTOR,
                    Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR);
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
        } else if (plusPressed(e.getKeyCode())) {
            getMainPanel().getControlPanel().zoomInX(Constants.WHEEL_ZOOM_IN_FACTOR,
                    Constants.WHEEL_ZOOM_IN_FACTOR);
            getMainPanel().getControlPanel().zoomInY(Constants.WHEEL_ZOOM_IN_FACTOR);
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
        } else if (e.getKeyCode() == KeyEvent.VK_S) {
            if ((getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED)
                    || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR)) {
                setStartingAngle((getStartingAngle() % TWO_PI) + ANGLE_ROTATION_UNIT);
                getControlPanel().displayedPhylogenyMightHaveChanged(false);
            }
        } else if (e.getKeyCode() == KeyEvent.VK_A) {
            if ((getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED)
                    || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR)) {
                setStartingAngle((getStartingAngle() % TWO_PI) - ANGLE_ROTATION_UNIT);
                if (getStartingAngle() < 0) {
                    setStartingAngle(TWO_PI + getStartingAngle());
                }
                getControlPanel().displayedPhylogenyMightHaveChanged(false);
            }
        } else if (e.getKeyCode() == KeyEvent.VK_D) {
            boolean selected = false;
            if (getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.HORIZONTAL) {
                getOptions().setNodeLabelDirection(NODE_LABEL_DIRECTION.RADIAL);
                selected = true;
            } else {
                getOptions().setNodeLabelDirection(NODE_LABEL_DIRECTION.HORIZONTAL);
            }
            if (getMainPanel().getMainFrame() == null) {
                // Must be "E" applet version.
                final ArchaeopteryxE ae = (ArchaeopteryxE) ((MainPanelApplets) getMainPanel()).getApplet();
                if (ae.getlabelDirectionCbmi() != null) {
                    ae.getlabelDirectionCbmi().setSelected(selected);
                }
            } else {
                getMainPanel().getMainFrame().getlabelDirectionCbmi().setSelected(selected);
            }
            repaint();
        } else if (e.getKeyCode() == KeyEvent.VK_X) {
            switchDisplaygetPhylogenyGraphicsType();
            repaint();
        } else if (e.getKeyCode() == KeyEvent.VK_C) {
            cycleColors();
            repaint();
        } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_O)) {
            MainFrame.cycleOverview(getOptions(), this);
            repaint();
        } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_I)) {
            increaseOvSize();
        } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_U)) {
            decreaseOvSize();
        }
        e.consume();
    }
}

From source file:savant.view.swing.Savant.java

private void initMenu() {
    loadGenomeItem.setAccelerator(/*www .j  av a  2 s  . c om*/
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G, MiscUtils.MENU_MASK));
    loadFromFileItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, MiscUtils.MENU_MASK));
    loadFromURLItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, MiscUtils.MENU_MASK));
    loadFromDataSourcePluginItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, MiscUtils.MENU_MASK));
    openProjectItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, MiscUtils.MENU_MASK));
    saveProjectItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, MiscUtils.MENU_MASK));
    saveProjectAsItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
            MiscUtils.MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK));
    formatItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, MiscUtils.MENU_MASK));
    exitItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, MiscUtils.MENU_MASK));
    undoItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, MiscUtils.MENU_MASK));
    redoItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Y, MiscUtils.MENU_MASK));
    bookmarkItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, MiscUtils.MENU_MASK));
    navigationItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R,
            java.awt.event.InputEvent.SHIFT_MASK | MiscUtils.MENU_MASK));
    panLeftItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_LEFT,
            java.awt.event.InputEvent.SHIFT_MASK));
    panRightItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_RIGHT,
            java.awt.event.InputEvent.SHIFT_MASK));
    zoomInItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_UP,
            java.awt.event.InputEvent.SHIFT_MASK));
    zoomOutItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DOWN,
            java.awt.event.InputEvent.SHIFT_MASK));
    toStartItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_HOME,
            java.awt.event.InputEvent.SHIFT_MASK));
    toEndItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_END,
            java.awt.event.InputEvent.SHIFT_MASK));
    preferencesItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, MiscUtils.MENU_MASK));
    crosshairItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_J, MiscUtils.MENU_MASK));
    plumblineItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_K, MiscUtils.MENU_MASK));
    spotlightItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, MiscUtils.MENU_MASK));
    bookmarksItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B,
            MiscUtils.MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK));
    genomeItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
            MiscUtils.MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK));
    rulerItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L,
            MiscUtils.MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK));
    statusBarItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
            MiscUtils.MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK));
    pluginToolbarItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T,
            MiscUtils.MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK));
    exportItem.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, MiscUtils.MENU_MASK));

    if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
        tutorialsItem.setEnabled(false);
        userManualItem.setEnabled(false);
        websiteItem.setEnabled(false);
    }
    initBrowseMenu();
    try {
        RecentTracksController.getInstance().populateMenu(recentTrackMenu);
        RecentProjectsController.getInstance().populateMenu(recentProjectMenu);
    } catch (IOException ex) {
        LOG.error("Unable to populate Recent Items menu.", ex);
    }

}

From source file:com.monead.semantic.workbench.SemanticWorkbench.java

/**
 * Create the edit menu//  ww w  . j a  va 2s  .co m
 * 
 * @return The edit menu
 */
private JMenu setupEditMenu() {
    final JMenu menu = new JMenu("Edit");

    menu.setMnemonic(KeyEvent.VK_E);
    menu.setToolTipText("Menu items related to editing the ontology");

    editFind = new JMenuItem("Find (in assertions)");
    editFind.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, KeyEvent.CTRL_MASK));
    editFind.setMnemonic(KeyEvent.VK_F);
    editFind.setToolTipText("Find text in the assertions editor");
    editFind.addActionListener(new FindAssertionsTextListener());
    menu.add(editFind);

    editFindNextMatch = new JMenuItem("Next (matching assertion text)");
    editFindNextMatch.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK));
    editFindNextMatch.setMnemonic(KeyEvent.VK_N);
    editFindNextMatch.setToolTipText("Find next text match in the assertions editor");
    editFindNextMatch.addActionListener(new FindNextAssertionsTextListener());
    menu.add(editFindNextMatch);

    menu.addSeparator();

    editCommentToggle = new JMenuItem("Toggle Comment");
    editCommentToggle.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK));
    editCommentToggle.setMnemonic(KeyEvent.VK_T);
    editCommentToggle
            .setToolTipText("Switch the chosen assertion or query lines between commented and not commented");
    editCommentToggle.addActionListener(new CommentToggleListener());
    editCommentToggle.setEnabled(false);
    menu.add(editCommentToggle);

    editInsertPrefixes = new JMenuItem("Insert Prefixes");
    editInsertPrefixes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK));
    editInsertPrefixes.setMnemonic(KeyEvent.VK_I);
    editInsertPrefixes.setToolTipText("Insert standard prefixes (namespaces)");
    editInsertPrefixes.addActionListener(new InsertPrefixesListener());
    menu.add(editInsertPrefixes);

    menu.addSeparator();

    editExpandAllTreeNodes = new JMenuItem("Expand Entire Tree");
    editExpandAllTreeNodes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, ActionEvent.ALT_MASK));
    editExpandAllTreeNodes.setMnemonic(KeyEvent.VK_E);
    editExpandAllTreeNodes.setToolTipText("Expand all tree nodes");
    editExpandAllTreeNodes.addActionListener(new ExpandTreeListener());
    menu.add(editExpandAllTreeNodes);

    editCollapseAllTreeNodes = new JMenuItem("Collapse Entire Tree");
    editCollapseAllTreeNodes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, ActionEvent.ALT_MASK));
    editCollapseAllTreeNodes.setMnemonic(KeyEvent.VK_C);
    editCollapseAllTreeNodes.setToolTipText("Expand all tree nodes");
    editCollapseAllTreeNodes.addActionListener(new CollapseTreeListener());
    menu.add(editCollapseAllTreeNodes);

    menu.addSeparator();

    editEditListOfSparqlServiceUrls = new JMenuItem("Edit SPARQL Service URLs List");
    editEditListOfSparqlServiceUrls.setMnemonic(KeyEvent.VK_S);
    editEditListOfSparqlServiceUrls.setToolTipText("Remove unwanted URLs from the dropdown list");
    editEditListOfSparqlServiceUrls.addActionListener(new EditListOfSparqlServiceUrls());
    menu.add(editEditListOfSparqlServiceUrls);

    return menu;
}

From source file:com.monead.semantic.workbench.SemanticWorkbench.java

/**
 * Create the model menu/*from   w  ww  .  j  a  v  a2  s  .  co  m*/
 * 
 * @return The model menu
 */
private JMenu setupModelMenu() {
    final JMenu menu = new JMenu("Model");

    menu.setMnemonic(KeyEvent.VK_M);
    menu.setToolTipText("Menu items related to viewing the model");

    modelCreateTreeView = new JMenuItem("Create Tree");
    modelCreateTreeView.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.ALT_MASK));
    modelCreateTreeView.setMnemonic(KeyEvent.VK_T);
    modelCreateTreeView.setToolTipText("Create tree representation of current model");
    modelCreateTreeView.addActionListener(new GenerateTreeListener());
    menu.add(modelCreateTreeView);

    modelListInferredTriples = new JMenuItem("Identify Inferred Triples");
    modelListInferredTriples.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.ALT_MASK));
    modelListInferredTriples.setMnemonic(KeyEvent.VK_I);
    modelListInferredTriples.setToolTipText("Create a list of inferred triples from the current model");
    modelListInferredTriples.addActionListener(new GenerateInferredTriplesListener());
    menu.add(modelListInferredTriples);

    menu.addSeparator();

    filterResetTree = new JMenuItem("Clear Tree");
    filterResetTree
            .setToolTipText("Remove the tree view of the ontology. This may help if memory is running low");
    filterResetTree.addActionListener(new ClearTreeModelListener());
    menu.add(filterResetTree);

    return menu;
}

From source file:com.projity.pm.graphic.frames.GraphicManager.java

public void setToolBarAndMenus(final Container contentPane) {
    JToolBar toolBar;// w w  w  .j a  va2 s. c o m
    if (Environment.isRibbonUI()) {
        if (Environment.isNeedToRestart()) {
            contentPane.add(new JLabel(Messages.getString("Error.restart")), BorderLayout.CENTER);
            return;
        }

        setRibbon((JRibbonFrame) container, getMenuManager());

        //         JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR_WITH_NO_SUB_VIEW_OPTION);
        //         topTabs = new TabbedNavigation();
        //         JComponent tabs = topTabs.createContentPanel(getMenuManager(),viewToolBar,0,JTabbedPane.TOP,true);
        //         tabs.setAlignmentX(0.0f); // so it is left justified
        //
        //
        //          Box top = new Box(BoxLayout.Y_AXIS);
        //          JComponent bottom;
        //         top.add(tabs);
        //         bottom = new TabbedNavigation().createContentPanel(getMenuManager(),viewToolBar,1,JTabbedPane.BOTTOM,false);
        //         contentPane.add(top, BorderLayout.BEFORE_FIRST_LINE);
        //         contentPane.add(bottom,BorderLayout.AFTER_LAST_LINE);
        //         if (Environment.isNewLaf())
        //            contentPane.setBackground(Color.WHITE);

        //         if (Environment.isMac()){
        //            //System.setProperty("apple.laf.useScreenMenuBar","true");
        //            //System.setProperty("com.apple.mrj.application.apple.menu.about.name", Messages.getMetaString("Text.ShortTitle"));
        //            JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone()?MenuManager.MAC_STANDARD_MENU:MenuManager.SERVER_STANDARD_MENU);
        //            //((JComponent)menu).setBorder(BorderFactory.createEmptyBorder());
        //
        //            ((JFrame)container).setJMenuBar(menu);
        //            projectListMenu = (JMenu) menu.getComponent(5);
        //         }

    } else if (Environment.isNewLook()) {
        if (Environment.isNeedToRestart()) {
            contentPane.add(new JLabel(Messages.getString("Error.restart")), BorderLayout.CENTER);
            return;
        }

        toolBar = getMenuManager().getToolBar(MenuManager.BIG_TOOL_BAR);
        if (!getLafManager().isToolbarOpaque())
            toolBar.setOpaque(false);
        if (!isApplet())
            getMenuManager().setActionVisible(ACTION_FULL_SCREEN, false);

        if (Environment.isExternal()) // external users only see project team
            getMenuManager().setActionVisible(ACTION_TEAM_FILTER, false);

        toolBar.addSeparator(new Dimension(20, 20));
        toolBar.add(new Box.Filler(new Dimension(0, 0), new Dimension(0, 0),
                new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)));
        toolBar.add(((DefaultFrameManager) getFrameManager()).getProjectComboPanel());
        toolBar.add(Box.createRigidArea(new Dimension(20, 20)));
        if (Environment.isNewLaf())
            toolBar.setBackground(Color.WHITE);
        toolBar.setFloatable(false);
        toolBar.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        Box top;
        JComponent bottom;

        top = new Box(BoxLayout.Y_AXIS);
        toolBar.setAlignmentX(0.0f); // so it is left justified
        top.add(toolBar);

        JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR_WITH_NO_SUB_VIEW_OPTION);
        topTabs = new TabbedNavigation();
        JComponent tabs = topTabs.createContentPanel(getMenuManager(), viewToolBar, 0, JTabbedPane.TOP, true);
        tabs.setAlignmentX(0.0f); // so it is left justified

        top.add(tabs);
        bottom = new TabbedNavigation().createContentPanel(getMenuManager(), viewToolBar, 1, JTabbedPane.BOTTOM,
                false);
        contentPane.add(top, BorderLayout.BEFORE_FIRST_LINE);
        contentPane.add(bottom, BorderLayout.AFTER_LAST_LINE);
        if (Environment.isNewLaf())
            contentPane.setBackground(Color.WHITE);

        if (Environment.isMac()) {
            //System.setProperty("apple.laf.useScreenMenuBar","true");
            //System.setProperty("com.apple.mrj.application.apple.menu.about.name", Messages.getMetaString("Text.ShortTitle"));
            JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone() ? MenuManager.MAC_STANDARD_MENU
                    : MenuManager.SERVER_STANDARD_MENU);
            //((JComponent)menu).setBorder(BorderFactory.createEmptyBorder());

            ((JFrame) container).setJMenuBar(menu);
            projectListMenu = (JMenu) menu.getComponent(5);
        }

    } else {

        toolBar = getMenuManager().getToolBar(
                Environment.isMac() ? MenuManager.MAC_STANDARD_TOOL_BAR : MenuManager.STANDARD_TOOL_BAR);
        filterToolBarManager = FilterToolBarManager.create(getMenuManager());
        filterToolBarManager.addButtons(toolBar);
        contentPane.add(toolBar, BorderLayout.BEFORE_FIRST_LINE);
        JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR);
        viewToolBar.setOrientation(JToolBar.VERTICAL);
        viewToolBar.setRollover(true);
        contentPane.add(viewToolBar, BorderLayout.WEST);

        JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone()
                ? (Environment.isMac() ? MenuManager.MAC_STANDARD_MENU : MenuManager.STANDARD_MENU)
                : MenuManager.SERVER_STANDARD_MENU);

        if (!Environment.isMac()) {
            ((JComponent) menu).setBorder(BorderFactory.createEmptyBorder());
            JMenuItem logo = (JMenuItem) menu.getComponent(0);
            logo.setBorder(BorderFactory.createEmptyBorder());
            logo.setMaximumSize(new Dimension(124, 52));
            logo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        }
        ((JFrame) container).setJMenuBar(menu);
        projectListMenu = (JMenu) menu.getComponent(Environment.isMac() ? 5 : 6);
    }

    //accelerators
    addCtrlAccel(KeyEvent.VK_G, ACTION_GOTO, null);
    addCtrlAccel(KeyEvent.VK_L, ACTION_GOTO, null);
    addCtrlAccel(KeyEvent.VK_F, ACTION_FIND, null);
    addCtrlAccel(KeyEvent.VK_Z, ACTION_UNDO, null); //- Sanhita
    addCtrlAccel(KeyEvent.VK_Y, ACTION_REDO, null);
    addCtrlAccel(KeyEvent.VK_N, ACTION_NEW_PROJECT, null);
    addCtrlAccel(KeyEvent.VK_O, ACTION_OPEN_PROJECT, null);
    addCtrlAccel(KeyEvent.VK_S, ACTION_SAVE_PROJECT, null);
    addCtrlAccel(KeyEvent.VK_P, ACTION_PRINT, null); //-Sanhita
    addCtrlAccel(KeyEvent.VK_I, ACTION_INSERT_TASK, null);
    addCtrlAccel(KeyEvent.VK_PERIOD, ACTION_INDENT, null);
    addCtrlAccel(KeyEvent.VK_COMMA, ACTION_OUTDENT, null);
    addCtrlAccel(KeyEvent.VK_PLUS, ACTION_EXPAND, new ExpandAction());
    addCtrlAccel(KeyEvent.VK_ADD, ACTION_EXPAND, new ExpandAction());
    addCtrlAccel(KeyEvent.VK_EQUALS, ACTION_EXPAND, new ExpandAction());
    addCtrlAccel(KeyEvent.VK_MINUS, ACTION_COLLAPSE, new CollapseAction());
    addCtrlAccel(KeyEvent.VK_SUBTRACT, ACTION_COLLAPSE, new CollapseAction());

    // To force a recalculation. This normally shouldn't be needed.
    addCtrlAccel(KeyEvent.VK_R, ACTION_RECALCULATE, new RecalculateAction());
}