Example usage for javax.swing JMenu add

List of usage examples for javax.swing JMenu add

Introduction

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

Prototype

public JMenuItem add(Action a) 

Source Link

Document

Creates a new menu item attached to the specified Action object and appends it to the end of this menu.

Usage

From source file:net.sf.jabref.gui.ImportInspectionDialog.java

private void insertNodes(JMenu menu, GroupTreeNode node) {
    final AbstractAction action = getAction(node);

    if (node.getNumberOfChildren() == 0) {
        menu.add(action);
        if (action.isEnabled()) {
            menu.setEnabled(true);//from  ww  w  .  j av a2 s  .  co  m
        }
        return;
    }

    JMenu submenu;
    if (node.getGroup() instanceof AllEntriesGroup) {
        for (GroupTreeNode child : node.getChildren()) {
            insertNodes(menu, child);
        }
    } else {
        submenu = new JMenu('[' + node.getName() + ']');
        // setEnabled(true) is done above/below if at least one menu
        // entry (item or submenu) is enabled
        submenu.setEnabled(action.isEnabled());
        submenu.add(action);
        submenu.add(new JPopupMenu.Separator());
        for (GroupTreeNode child : node.getChildren()) {
            insertNodes(submenu, child);
        }
        menu.add(submenu);
        if (submenu.isEnabled()) {
            menu.setEnabled(true);
        }
    }
}

From source file:com.mgmtp.perfload.loadprofiles.ui.AppFrame.java

private void initMenuBar(final JMenuBar menuBar) {
    JMenu menu = new JMenu("File");
    menu.setMnemonic('F');
    menu.add(fileNewLoadProfileConfigAction);
    menu.add(fileOpenLoadProfileConfigAction);
    menu.addSeparator();/*from  w  ww  .j  a v a  2 s  .c o m*/
    menu.add(fileSaveLoadProfileConfigAction);
    menu.add(fileSaveLoadProfileConfigAsAction);
    menu.addSeparator();
    menu.add(new FileExitAction(eventBus));
    menuBar.add(menu);

    menu = new JMenu("Tools");
    menu.setMnemonic('T');
    menu.add(toolsAddStairsAction);
    menu.add(toolsAddOneTimeAction);
    menu.add(toolsAddMarkerAction);
    menu.add(toolsDeleteLoadProfileEntityAction);
    menu.addSeparator();
    menu.add(toolsExportEventListAction);
    menu.addSeparator();
    menu.add(toolsSettingsAction);
    menuBar.add(menu);

    menu = new JMenu("Help");
    menu.setMnemonic('H');
    menu.add(helpAboutAction);
    menuBar.add(menu);
}

From source file:gui.DownloadManagerGUI.java

private JMenuBar initMenuBar() {
    JMenuBar menuBar = new JMenuBar();

    /////////////////////////////////////////////////////////////////////////
    JMenu fileMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.fileMenu.name"));
    exportDataItem = new JMenuItem("Export Data...");
    importDataItem = new JMenuItem("Import Data...");
    exitItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.exitItem.name"));
    exitItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.exitItem.iconPath")))); // NOI18N

    exportDataItem.setEnabled(false);//w  ww  .  j a v  a2s.c  om
    importDataItem.setEnabled(false);

    //     fileMenu.add(exportDataItem);
    //     fileMenu.add(importDataItem);
    fileMenu.addSeparator();
    fileMenu.add(exitItem);

    /////////////////////////////////////////////////////////////////////////
    JMenu windowMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.windowMenu.name"));
    JMenu showMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.showMenu.name"));
    prefsItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.prefsItem.name"));
    prefsItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.prefsItem.iconPath"))));

    JCheckBoxMenuItem showFormItem = new JCheckBoxMenuItem(
            messagesBundle.getString("downloadManagerGUI.showFormItem.name"));
    showFormItem.setSelected(true);

    showMenu.add(showFormItem);
    windowMenu.add(showMenu);
    windowMenu.add(prefsItem);

    exportDataItem.addActionListener(this);
    importDataItem.addActionListener(this);
    exitItem.addActionListener(this);
    prefsItem.addActionListener(this);

    /////////////////////////////////////////////////////////////////////////
    JMenu downloadsMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.downloadsMenu.name"));
    newDownloadItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.newDownloadItem.name"));
    newDownloadItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.newDownloadItem.iconPath"))));
    openItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.openItem.name"));
    openFolderItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.openFolderItem.name"));
    resumeItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.resumeItem.name"));
    resumeItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.resumeItem.iconPath"))));
    pauseItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.pauseItem.name"));
    pauseItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.pauseItem.iconPath"))));
    pauseAllItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.pauseAllItem.name"));
    pauseAllItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.pauseAllItem.iconPath"))));
    clearItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.clearItem.name"));
    clearItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.clearItem.iconPath"))));
    clearAllCompletedItem = new JMenuItem(
            messagesBundle.getString("downloadManagerGUI.clearAllCompletedItem.name"));
    clearAllCompletedItem.setIcon(new javax.swing.ImageIcon(getClass()
            .getResource(messagesBundle.getString("downloadManagerGUI.clearAllCompletedItem.iconPath"))));
    reJoinItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.reJoinItem.name"));
    reJoinItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.reJoinItem.iconPath"))));
    reDownloadItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.reDownloadItem.name"));
    reDownloadItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.reDownloadItem.iconPath"))));

    moveToQueueItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.moveToQueueItem.name"));

    removeFromQueueItem = new JMenuItem(
            messagesBundle.getString("downloadManagerGUI.removeFromQueueItem.name"));
    propertiesItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.propertiesItem.name"));
    propertiesItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.propertiesItem.iconPath"))));

    downloadsMenu.add(newDownloadItem);
    downloadsMenu.add(new JSeparator());
    downloadsMenu.add(openItem);
    downloadsMenu.add(openFolderItem);
    downloadsMenu.add(new JSeparator());
    downloadsMenu.add(resumeItem);
    downloadsMenu.add(pauseItem);
    downloadsMenu.add(pauseAllItem);
    downloadsMenu.add(new JSeparator());
    downloadsMenu.add(clearItem);
    downloadsMenu.add(clearAllCompletedItem);
    downloadsMenu.add(new JSeparator());
    downloadsMenu.add(reJoinItem);
    downloadsMenu.add(reDownloadItem);
    downloadsMenu.add(new JSeparator());
    downloadsMenu.add(moveToQueueItem);
    downloadsMenu.add(removeFromQueueItem);
    downloadsMenu.add(new JSeparator());
    downloadsMenu.add(propertiesItem);

    newDownloadItem.addActionListener(this);
    openItem.addActionListener(this);
    openFolderItem.addActionListener(this);
    resumeItem.addActionListener(this);
    pauseItem.addActionListener(this);
    pauseAllItem.addActionListener(this);
    clearItem.addActionListener(this);
    clearAllCompletedItem.addActionListener(this);
    reDownloadItem.addActionListener(this);
    moveToQueueItem.addActionListener(this);
    removeFromQueueItem.addActionListener(this);
    propertiesItem.addActionListener(this);

    setStateOfMenuItems();

    /////////////////////////////////////////////////////////////////////////
    JMenu helpMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.helpMenu.name"));
    aboutItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.aboutItem.name"));
    aboutItem.setIcon(new javax.swing.ImageIcon(
            getClass().getResource(messagesBundle.getString("downloadManagerGUI.aboutItem.iconPath"))));

    helpMenu.add(aboutItem);

    aboutItem.addActionListener(this);

    menuBar.add(fileMenu);
    menuBar.add(windowMenu);
    menuBar.add(downloadsMenu);
    menuBar.add(helpMenu);

    showFormItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ev.getSource();

            if (menuItem.isSelected()) {
                mainSplitPane.setDividerLocation((int) categoryPanel.getMinimumSize().getWidth());
            }

            categoryPanel.setVisible(menuItem.isSelected());
        }
    });

    fileMenu.setMnemonic(KeyEvent.VK_F);
    exitItem.setMnemonic(KeyEvent.VK_X);

    prefsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK));

    exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));

    importDataItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK));

    return menuBar;
}

From source file:com.fratello.longevity.smooth.AppGUI.java

private void initialize() {
    LabelMaxSize = 0;/*w w  w . j ava  2 s . com*/

    ActiveGUI = true;
    GUI_Start = false;
    GUI_Pause = true;
    GUI_Stop = false;
    ran_at_least_once = false;

    execute();

    initializeFields();

    frmFileSystemSearch = new JFrame();
    frmFileSystemSearch.setTitle("Smooth Longevity Fratello");
    frmFileSystemSearch.setBounds(100, 100, 450, 300);
    frmFileSystemSearch.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmFileSystemSearch.setResizable(false);

    UIManager.put("PopupMenu.border", BorderFactory.createLineBorder(Color.black, 1));

    JMenuBar menuBar = new JMenuBar();
    frmFileSystemSearch.setJMenuBar(menuBar);

    JMenu mnNewMenu = new JMenu("File");
    menuBar.add(mnNewMenu);

    JMenuItem mntmFirst = new JMenuItem("Open Directory");
    mntmFirst.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openFileChooserDir(mntmFirst);
        }
    });
    mnNewMenu.add(mntmFirst);

    JMenuItem mntmExit = new JMenuItem("Exit");
    mntmExit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            frmFileSystemSearch.dispose();
        }
    });
    mnNewMenu.add(mntmExit);

    JMenu mnHelp = new JMenu("Help");
    menuBar.add(mnHelp);

    JMenuItem mntmAbout = new JMenuItem("About");
    mnHelp.add(mntmAbout);

    JMenuItem mntmTutorials = new JMenuItem("Tutorials");
    mnHelp.add(mntmTutorials);

    JMenuItem mntmCheckForUpdates = new JMenuItem("Check for Updates");
    mnHelp.add(mntmCheckForUpdates);

    String ppallink = "https://www.paypal.com/cgi-bin/webscr" + "?cmd=" + "_donations" + "&business="
            + "8YUJNSN6KFV54" + "&lc=" + "US" + "&item_name="
            + "Personal%20funds%20for%20programming%20at%20university" + "&currency_code=" + "USD" + "&bn="
            + "PP%2dDonationsBF" + "%3abtn_donateCC_LG%2egif%3aNonHosted";

    JButton btnDonate = new JButton("Donate");
    btnDonate.setToolTipText("<html>Open default Internet browser <br>(Chrome, FireFox, etc.)</html>");
    btnDonate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openWebPage(ppallink);
        }
    });
    btnDonate.setBounds(159, 176, 90, 25);
    menuBar.add(btnDonate);

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    frmFileSystemSearch.getContentPane().add(tabbedPane, BorderLayout.CENTER);

    // ---------------------------- JPanels ------------------------------
    JPanel panel = new JPanel();
    tabbedPane.addTab("Start Directory", null, panel, null);

    JPanel panel_1 = new JPanel();
    tabbedPane.addTab("Search Setup", null, panel_1, null);
    panel_1.setLayout(null);

    JPanel panel_2 = new JPanel();
    tabbedPane.addTab("Run Program", null, panel_2, null);
    panel_2.setLayout(null);

    JPanel panel_3 = new JPanel();
    tabbedPane.addTab("Information", null, panel_3, null);
    panel_3.setBounds(10, 11, 409, 154);
    GridBagLayout gbl_panel_3 = new GridBagLayout();
    gbl_panel_3.columnWidths = new int[] { 0, 0, 0 };
    gbl_panel_3.rowHeights = new int[] { 0, 0, 0 };
    gbl_panel_3.columnWeights = new double[] { 1.0, 1.0, 1.0 };
    gbl_panel_3.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
    panel_3.setLayout(gbl_panel_3);

    // ------------- Dynamic Update - Swingworker Components -------------
    SentinelProgressBar = new JProgressBar();
    SentinelProgressBar.setMaximumSize(new Dimension(146, 14));
    SentinelProgressBar.setMaximum(1000);
    SentinelProgressBar.setBounds(74, 187, 146, 14);
    panel_2.add(SentinelProgressBar);

    SentinelProgressLabel = new JLabel();
    SentinelProgressLabel.setToolTipText("Time needed to finish the program in progress");
    SentinelProgressLabel.setBounds(333, 181, 86, 20);
    panel_2.add(SentinelProgressLabel);

    // -------------------------------------------------------------------
    // ------------------------ JPanel Components ------------------------
    JLabel lblCurrentDirectory = new JLabel("Current Directory");
    panel.add(lblCurrentDirectory);

    userSelectedDirectories = new JTextField();
    panel.add(userSelectedDirectories);
    userSelectedDirectories.setColumns(35);

    JButton btnBrowse = new JButton("Browse");
    btnBrowse.setToolTipText("Locate directory in system");
    btnBrowse.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openFileChooserDir(btnBrowse);
        }
    });
    panel.add(btnBrowse);

    JButton btnClear = new JButton("Clear");
    btnClear.setToolTipText("Deletes the current directory shown");
    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            userSelectedDirectories.setText("");
            clearSourceDirectory();
        }
    });
    panel.add(btnClear);

    // -------------------------------------------------------------------
    // ----------------------- JPanel_1 Components -----------------------

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Extension :: [Check Box]
    chckbxExt = new JCheckBox("Extension");
    chckbxExt.setToolTipText("Check to ignore file extensions");
    chckbxExt.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Ext", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Ext", false);
        }
    });
    chckbxExt.setBounds(8, 15, 97, 23);
    panel_1.add(chckbxExt);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Hash :: [Check Box]
    chckbxHash = new JCheckBox("Hash");
    chckbxHash.setToolTipText("Check to compare by hashing files (FAST)");
    chckbxHash.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Hash", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Hash", false);
        }
    });
    chckbxHash.setBounds(8, 45, 97, 23);
    panel_1.add(chckbxHash);

    // Hash :: [Combo Box]
    comboBoxHash = new JComboBox<String>();
    comboBoxHash.setToolTipText(
            "<html>Hash algorithm to use in file hashing <br>(note - SHA-512 may not be <br>supported by your computer)</html>");
    comboBoxHash.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            @SuppressWarnings("unchecked")
            JComboBox<String> cb = (JComboBox<String>) e.getSource();
            String UIselect = (String) cb.getSelectedItem();
            cf.setHashString(UIselect);
        }
    });
    comboBoxHash
            .setModel(new DefaultComboBoxModel<String>(new String[] { "MD5", "SHA-1", "SHA-256", "SHA-512" }));
    comboBoxHash.setBounds(150, 44, 75, 25);
    panel_1.add(comboBoxHash);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Name :: [Check Box]
    chckbxName = new JCheckBox("Name");
    chckbxName.setToolTipText("Name tool-tip goes here");
    chckbxName.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Name", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Name", false);
        }
    });
    chckbxName.setBounds(8, 75, 97, 23);
    panel_1.add(chckbxName);

    // Name :: [Text Field]
    namePercentMatchTextField = new JFormattedTextField(new Double(0.0d));
    namePercentMatchTextField.setFormatterFactory(new DoubleDocListener(namePercentMatchTextField));
    namePercentMatchTextField.getDocument()
            .addDocumentListener(new DoubleDocListener(namePercentMatchTextField));
    namePercentMatchTextField.setToolTipText("Match file names by percentage [00.00-100.00]");
    namePercentMatchTextField.setBounds(150, 74, 110, 25);
    panel_1.add(namePercentMatchTextField);
    namePercentMatchTextField.setColumns(10);

    // Name :: [Combo Box]
    comboBoxNames = new JComboBox<String>();
    comboBoxNames.setToolTipText("Algorithm to compare names");
    comboBoxNames.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            @SuppressWarnings("unchecked")
            JComboBox<String> cb = (JComboBox<String>) e.getSource();
            String UIselect = (String) cb.getSelectedItem();
            cf.setMatchingAlgorithm(UIselect);
        }
    });
    comboBoxNames.setModel(new DefaultComboBoxModel<String>(new String[] { "Bitap", "Cosine",
            "DamerauLevenshtein", "DynamicTimeWarpingStandard1", "DynamicTimeWarpingStandard2", "Hamming",
            "Hirschberg", "JaccardIndex", "JaroWinkler", "Levenshtein", "NeedlemanWunsch", "SmithWaterman",
            "SorensenSimilarityIndex", "WagnerFischer" }));
    comboBoxNames.setBounds(265, 74, 150, 25);
    panel_1.add(comboBoxNames);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Size :: [Check Box]
    chckbxSize = new JCheckBox("Size");
    chckbxSize.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Size", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Size", false);
        }
    });
    chckbxSize.setBounds(8, 105, 97, 23);
    panel_1.add(chckbxSize);

    // Size :: [Text Field]
    sizePercentMatchTextField = new JFormattedTextField(new Double(0.0d));
    sizePercentMatchTextField.setFormatterFactory(new DoubleDocListener(sizePercentMatchTextField));
    sizePercentMatchTextField.getDocument()
            .addDocumentListener(new DoubleDocListener(sizePercentMatchTextField));
    sizePercentMatchTextField.setToolTipText("Match file sizes by percentage [00.00-100.00]");
    sizePercentMatchTextField.setBounds(150, 104, 110, 25);
    panel_1.add(sizePercentMatchTextField);
    sizePercentMatchTextField.setColumns(10);

    // Size :: [Combo Box]
    comboBoxSize = new JComboBox<String>();
    comboBoxSize.setToolTipText("Specify byte grouping");
    comboBoxSize.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            @SuppressWarnings("unchecked")
            JComboBox<String> cb = (JComboBox<String>) e.getSource();
            String UIselect = (String) cb.getSelectedItem();
            cf.setMetricSize(UIselect);
        }
    });
    comboBoxSize.setModel(
            new DefaultComboBoxModel<String>(new String[] { "BYTE", "KILOBYTE", "MEGABYTE", "GIGABYTE" }));
    comboBoxSize.setBounds(265, 104, 150, 25);
    panel_1.add(comboBoxSize);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Thorough :: [Check Box]
    chckbxThorough = new JCheckBox("Thorough");
    chckbxThorough.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setUse("Thorough", true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setUse("Thorough", false);
        }
    });
    chckbxThorough.setToolTipText("Check byte by byte");
    chckbxThorough.setBounds(8, 135, 97, 23);
    panel_1.add(chckbxThorough);

    // Thorough :: [Text Field]
    thoroughPercentMatchTextField = new JFormattedTextField(new Double(0.0d));
    thoroughPercentMatchTextField.setFormatterFactory(new DoubleDocListener(thoroughPercentMatchTextField));
    thoroughPercentMatchTextField.getDocument()
            .addDocumentListener(new DoubleDocListener(thoroughPercentMatchTextField));
    thoroughPercentMatchTextField.setToolTipText("Match file sizes by percentage [00.00-100.00]");
    thoroughPercentMatchTextField.setBounds(150, 134, 110, 25);
    panel_1.add(thoroughPercentMatchTextField);
    thoroughPercentMatchTextField.setColumns(10);

    // Thorough :: [Check Box]
    chckbxExitFast = new JCheckBox("Exit Fast");
    chckbxExitFast.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED)
                cf.setThoroughExitFirstByteMisMatch(true);
            else if (e.getStateChange() == ItemEvent.DESELECTED)
                cf.setThoroughExitFirstByteMisMatch(false);
        }
    });
    chckbxExitFast.setToolTipText("<html>When the first byte comparison <br>is a mis-match then stop</html>");
    chckbxExitFast.setBounds(265, 138, 105, 16);
    panel_1.add(chckbxExitFast);

    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    JButton btnSaveSearchSettings = new JButton("Save Search Settings");
    btnSaveSearchSettings.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            pollSearchSettings();
            cf.saveObject();
            // System.out.println(cf.toString()); // debug
        }
    });
    btnSaveSearchSettings.setBounds(292, 181, 140, 25);
    panel_1.add(btnSaveSearchSettings);

    JButton btnLoadSettings = new JButton("Load Settings");
    btnLoadSettings.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (!cf.loadObject())
                cf.setDefaultSettings();
            cacheUpdateGUISettings();
        }
    });
    btnLoadSettings.setBounds(148, 181, 140, 25);
    panel_1.add(btnLoadSettings);

    JButton btnDefaultSettings = new JButton("Use Default Settings");
    btnDefaultSettings.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            cf.setDefaultSettings();
            cacheUpdateGUISettings();
        }
    });
    btnDefaultSettings.setBounds(4, 181, 140, 25);
    panel_1.add(btnDefaultSettings);

    // -------------------------------------------------------------------
    // ----------------------- JPanel_2 Components -----------------------
    JLabel labelStatus = new JLabel("Progress");
    labelStatus.setBounds(10, 187, 54, 14);
    panel_2.add(labelStatus);

    JButton btnStart = new JButton("Start");
    btnStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            pollSearchSettings();
            if (!ran_at_least_once)
                ran_at_least_once = true;
            else {
                SentinelProgressBar.setValue(0);
                SentinelProgressLabel.setText("Waiting...");
            }
            try {
                if (multiSelection == null) {
                    JOptionPane.showMessageDialog(btnStart, "Please enter at least one directory.",
                            "Press OK to continue", JOptionPane.PLAIN_MESSAGE);
                    return;
                }
                setSourceDirectory(multiSelection);
                GUI_Start = true;
            } catch (Exception err) {
                err.printStackTrace();
            }
        }
    });
    btnStart.setBounds(40, 153, 89, 23);
    panel_2.add(btnStart);

    JButton btnStop = new JButton("Stop");
    btnStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            GUI_Stop = true;
        }
    });
    btnStop.setBounds(169, 153, 89, 23);
    panel_2.add(btnStop);

    JButton btnNewButton = new JButton("Pause");
    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            GUI_Pause = true;
        }
    });
    btnNewButton.setBounds(298, 153, 89, 23);
    panel_2.add(btnNewButton);

    JCheckBox chckbxDeleteDuplicateFiles = new JCheckBox("Delete duplicate files");
    chckbxDeleteDuplicateFiles.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            deleteCopyResults = true;
        }
    });
    chckbxDeleteDuplicateFiles.setBounds(230, 10, 150, 16);
    panel_2.add(chckbxDeleteDuplicateFiles);

    JCheckBox chckbxLogDuplicateFiles = new JCheckBox("Save duplicates to file");
    chckbxLogDuplicateFiles.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            saveCopyResults = true;
        }
    });
    chckbxLogDuplicateFiles.setBounds(230, 36, 150, 16);
    panel_2.add(chckbxLogDuplicateFiles);

    // -------------------------------------------------------------------
    // ----------------------- JPanel_3 Components -----------------------

    JLabel lblAbout = new JLabel("About");
    GridBagConstraints gbc_lblAbout = new GridBagConstraints();
    gbc_lblAbout.insets = new Insets(0, 0, 5, 5);
    gbc_lblAbout.gridx = 0;
    gbc_lblAbout.gridy = 0;
    panel_3.add(lblAbout, gbc_lblAbout);

    JLabel lblTutorials = new JLabel("Tutorials");
    GridBagConstraints gbc_lblTutorials = new GridBagConstraints();
    gbc_lblTutorials.insets = new Insets(0, 0, 5, 5);
    gbc_lblTutorials.gridx = 1;
    gbc_lblTutorials.gridy = 0;
    panel_3.add(lblTutorials, gbc_lblTutorials);

    JLabel lblUpdates = new JLabel("Updates");
    GridBagConstraints gbc_lblUpdates = new GridBagConstraints();
    gbc_lblUpdates.insets = new Insets(0, 0, 5, 0);
    gbc_lblUpdates.gridx = 2;
    gbc_lblUpdates.gridy = 0;
    panel_3.add(lblUpdates, gbc_lblUpdates);

    JButton btnInformation = new JButton("Information");
    btnInformation.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openWebPage(ppallink);
        }
    });
    GridBagConstraints gbc_btnInformation = new GridBagConstraints();
    gbc_btnInformation.insets = new Insets(0, 0, 0, 5);
    gbc_btnInformation.gridx = 0;
    gbc_btnInformation.gridy = 1;
    panel_3.add(btnInformation, gbc_btnInformation);

    JButton btnExamples = new JButton("Examples");
    btnExamples.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openWebPage(ppallink);
        }
    });
    GridBagConstraints gbc_btnExamples = new GridBagConstraints();
    gbc_btnExamples.insets = new Insets(0, 0, 0, 5);
    gbc_btnExamples.gridx = 1;
    gbc_btnExamples.gridy = 1;
    panel_3.add(btnExamples, gbc_btnExamples);

    JButton btnCheckNow = new JButton("Check Now");
    btnCheckNow.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            openWebPage(ppallink);
        }
    });
    GridBagConstraints gbc_btnCheckNow = new GridBagConstraints();
    gbc_btnCheckNow.gridx = 2;
    gbc_btnCheckNow.gridy = 1;
    panel_3.add(btnCheckNow, gbc_btnCheckNow);
}

From source file:de.tbuchloh.kiskis.gui.MainFramePanel.java

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

    _changeMasterPwdAction.setEnabled(Settings.isBufferingPwd());

    return fileMenu;
}

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

private void initFileMenu(JMenu mnFile) {
    mnFile.removeAll();//  w ww . j  ava  2s .  com

    // non-dynamic
    for (MyAction action : fileActions) {
        if (action == null) {
            mnFile.addSeparator();
        } else {
            JMenuItem item = mnFile.add(action);
            if (action.accelerator != null) {
                item.setAccelerator(action.accelerator);
            }
        }
    }

    // import (not in action list as doesn't appear on toolbar)
    mnFile.addSeparator();
    JMenu mnImport = new JMenu("Import");
    mnFile.add(mnImport);

    class ImportPair {
        String menuString;
        SupportedFileType type;

        public ImportPair(String menuString, SupportedFileType type) {
            super();
            this.menuString = menuString;
            this.type = type;
        }
    }
    for (final ImportPair type : new ImportPair[] {
            new ImportPair("Comma separated (CSV) text", SupportedFileType.CSV),
            new ImportPair("Tab separated text", SupportedFileType.TABBED),
            new ImportPair("Excel", SupportedFileType.EXCEL),
            new ImportPair("Shapefile (link geometry to original file)",
                    SupportedFileType.SHAPEFILE_LINKED_GEOM),
            new ImportPair("Shapefile (copy geometry into spreadsheet)",
                    SupportedFileType.SHAPEFILE_COPIED_GEOM), }) {
        mnImport.add(new AbstractAction(type.menuString) {

            @Override
            public void actionPerformed(ActionEvent e) {
                importFile(type.type);
            }
        });
    }

    // dynamic
    mnFile.addSeparator();
    List<File> recent = PreferencesManager.getSingleton().getRecentFiles();
    for (int i = 0; i < recent.size(); i++) {
        final File file = recent.get(i);
        String s = Integer.toString(i + 1) + ". " + file.getAbsolutePath();
        int maxLen = 100;
        if (s.length() > maxLen) {
            s = s.substring(0, maxLen) + "...";
        }
        mnFile.add(new MyAction(s, "Load file " + file.getAbsolutePath(), null, null, false, null) {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (!canCloseDatastore()) {
                    return;
                }

                openFile(file);
                updateAppearance();
            }

        });
    }

    // clear recent
    mnFile.addSeparator();
    mnFile.add(new MyAction("Clear recent files", "Clear recent files", null, null, false, null) {

        @Override
        public void actionPerformed(ActionEvent e) {
            PreferencesManager.getSingleton().clearRecentFiles();
        }
    });

    // finally exit
    mnFile.addSeparator();
    JMenuItem item = mnFile.add(new MyAction("Exit", "Exit", null, null, false,
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.Event.CTRL_MASK)) {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
            System.exit(0);
        }
    });
    item.setAccelerator(((MyAction) item.getAction()).accelerator);
    mnFile.validate();
}

From source file:edu.clemson.cs.nestbed.client.gui.ConfigManagerFrame.java

private final JMenu buildProfilingMenu() {
    final JMenu menu = new JMenu("Profiling");
    final JMenuItem deleteProfilingSymbol = new JMenuItem("Delete " + "Profiling " + "Symbol");
    final JMenuItem deleteProfilingMessage = new JMenuItem("Delete " + "Profiling " + "Message");

    deleteProfilingSymbol.addActionListener(new DeleteProgramProfilingSymbolListener());
    menu.add(deleteProfilingSymbol);

    deleteProfilingMessage.addActionListener(new DeleteProgramProfilingMessageSymbolListener());
    menu.add(deleteProfilingMessage);/*from   www.j a  v a2 s .  c  o m*/

    menu.addMenuListener(new MenuListener() {
        public void menuSelected(MenuEvent e) {
            setDeleteProfilingSymbolEnabled();
            setDeleteProfilingMessageEnabled();
        }

        private void setDeleteProfilingSymbolEnabled() {
            int row = profilingSymbolTable.getSelectedRow();

            deleteProfilingSymbol.setEnabled((row != -1) && (row != (profilingSymbolTable.getRowCount() - 1)));
        }

        private void setDeleteProfilingMessageEnabled() {
            int row = profilingMsgTable.getSelectedRow();

            deleteProfilingMessage.setEnabled((row != -1) && (row != (profilingMsgTable.getRowCount() - 1)));
        }

        public void menuCanceled(MenuEvent e) {
        }

        public void menuDeselected(MenuEvent e) {
        }

    });

    return menu;
}

From source file:com.diversityarrays.kdxplore.KDXploreFrame.java

private JMenuBar buildMenuBar() {

    RunMode runMode = RunMode.getRunMode();

    JMenuBar mb = new JMenuBar();

    mb.add(createMainMenu(runMode));/* www.jav a  2s . c  o  m*/

    if (!backupProviders.isEmpty()) {
        String toolsMenuLabel = Msg.MENU_TOOLS();
        JMenu toolsMenu = new JMenu(toolsMenuLabel);
        mb.add(toolsMenu);
        for (Action a : pluginInfo.getToolsMenuActions()) {
            toolsMenu.add(a);
        }

        Action backupAction = new AbstractAction(Msg.MENUITEM_BACKUP_DB()) {
            @Override
            public void actionPerformed(ActionEvent e) {
                doBackupDatabase();
            }
        };
        backupAction.putValue(Action.SMALL_ICON, KDClientUtils.getIcon(ImageId.DB_BACKUP));

        toolsMenu.add(backupAction);
        boolean seen = false;
        for (BackupProvider bp : backupProviders) {
            Action a = bp.getOfflineDataAction();
            if (a != null) {
                if (!seen) {
                    seen = true;
                    toolsMenu.add(new JSeparator());
                }
                toolsMenu.add(a);
            }
        }
    }

    mb.add(frameWindowOpener.getWindowsMenu());
    mb.add(createHelpMenu());

    return mb;
}

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

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

From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_demand.java

public void doPopup(final MouseEvent e, final int row, final Object itemId) {
    JPopupMenu popup = new JPopupMenu();

    final ITableRowFilter rf = callback.getVisualizationState().getTableRowFilter();
    final List<Demand> demandRowsInTheTable = getVisibleElementsInTable();

    /* Add the popup menu option of the filters */
    final List<Demand> selectedDemands = (List<Demand>) (List<?>) getSelectedElements().getFirst();
    if (!selectedDemands.isEmpty()) {
        final JMenu submenuFilters = new JMenu("Filters");
        final JMenuItem filterKeepElementsAffectedThisLayer = new JMenuItem(
                "This layer: Keep elements associated to this demand traffic");
        final JMenuItem filterKeepElementsAffectedAllLayers = new JMenuItem(
                "All layers: Keep elements associated to this demand traffic");
        submenuFilters.add(filterKeepElementsAffectedThisLayer);
        if (callback.getDesign().getNumberOfLayers() > 1)
            submenuFilters.add(filterKeepElementsAffectedAllLayers);
        filterKeepElementsAffectedThisLayer.addActionListener(new ActionListener() {
            @Override/*from  w w  w  .j a  v  a 2 s  .  co  m*/
            public void actionPerformed(ActionEvent e) {
                if (selectedDemands.size() > 1)
                    throw new RuntimeException();
                TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedDemands.get(0), true);
                callback.getVisualizationState().updateTableRowFilter(filter);
                callback.updateVisualizationJustTables();
            }
        });
        filterKeepElementsAffectedAllLayers.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (selectedDemands.size() > 1)
                    throw new RuntimeException();
                TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedDemands.get(0), false);
                callback.getVisualizationState().updateTableRowFilter(filter);
                callback.updateVisualizationJustTables();
            }
        });
        popup.add(submenuFilters);
        popup.addSeparator();
    }

    if (callback.getVisualizationState().isNetPlanEditable()) {
        popup.add(getAddOption());
        for (JComponent item : getExtraAddOptions())
            popup.add(item);
    }

    if (!demandRowsInTheTable.isEmpty()) {
        if (callback.getVisualizationState().isNetPlanEditable()) {
            if (row != -1) {
                if (popup.getSubElements().length > 0)
                    popup.addSeparator();

                JMenuItem removeItem = new JMenuItem("Remove " + networkElementType);

                removeItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        NetPlan netPlan = callback.getDesign();

                        try {
                            final Demand demand = netPlan.getDemandFromId((long) itemId);
                            demand.remove();
                            callback.getVisualizationState().resetPickedState();
                            callback.updateVisualizationAfterChanges(
                                    Collections.singleton(NetworkElementType.DEMAND));
                            callback.getUndoRedoNavigationManager().addNetPlanChange();
                        } catch (Throwable ex) {
                            ErrorHandling.addErrorOrException(ex, getClass());
                            ErrorHandling.showErrorDialog("Unable to remove " + networkElementType);
                        }
                    }
                });

                popup.add(removeItem);

                addPopupMenuAttributeOptions(e, row, itemId, popup);
            }

            JMenuItem removeItems = new JMenuItem("Remove all " + networkElementType + "s in the table");
            removeItems.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    NetPlan netPlan = callback.getDesign();

                    try {
                        if (rf == null)
                            netPlan.removeAllDemands();
                        else
                            for (Demand d : demandRowsInTheTable)
                                d.remove();

                        callback.getVisualizationState().resetPickedState();
                        callback.updateVisualizationAfterChanges(
                                Collections.singleton(NetworkElementType.DEMAND));
                        callback.getUndoRedoNavigationManager().addNetPlanChange();
                    } catch (Throwable ex) {
                        ex.printStackTrace();
                        ErrorHandling.showErrorDialog(ex.getMessage(),
                                "Unable to remove all " + networkElementType + "s");
                    }
                }
            });

            popup.add(removeItems);

            List<JComponent> extraOptions = getExtraOptions(row, itemId);
            if (!extraOptions.isEmpty()) {
                if (popup.getSubElements().length > 0)
                    popup.addSeparator();
                for (JComponent item : extraOptions)
                    popup.add(item);
            }
        }

        List<JComponent> forcedOptions = getForcedOptions();
        if (!forcedOptions.isEmpty()) {
            if (popup.getSubElements().length > 0)
                popup.addSeparator();
            for (JComponent item : forcedOptions)
                popup.add(item);
        }
    }

    popup.show(e.getComponent(), e.getX(), e.getY());
}