Example usage for javax.swing JMenuItem setAccelerator

List of usage examples for javax.swing JMenuItem setAccelerator

Introduction

In this page you can find the example usage for javax.swing JMenuItem setAccelerator.

Prototype

@BeanProperty(preferred = true, description = "The keystroke combination which will invoke the JMenuItem's actionlisteners without navigating the menu hierarchy")
public void setAccelerator(KeyStroke keyStroke) 

Source Link

Document

Sets the key combination which invokes the menu item's action listeners without navigating the menu hierarchy.

Usage

From source file:com.adobe.aem.demo.gui.AemDemo.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private void initialize() {

    // Initialize properties
    setDefaultProperties(AemDemoUtils/* ww w  . j a v a 2s  .c om*/
            .loadProperties(buildFile.getParentFile().getAbsolutePath() + File.separator + "build.properties"));
    setPersonalProperties(AemDemoUtils.loadProperties(buildFile.getParentFile().getAbsolutePath()
            + File.separator + "conf" + File.separator + "build-personal.properties"));

    // Constructing the main frame
    frameMain = new JFrame();
    frameMain.setBounds(100, 100, 700, 530);
    frameMain.getContentPane().setLayout(null);

    // Main menu bar for the Frame
    JMenuBar menuBar = new JMenuBar();

    JMenu mnAbout = new JMenu("AEM Demo Machine");
    mnAbout.setMnemonic(KeyEvent.VK_A);
    menuBar.add(mnAbout);

    JMenuItem mntmDoc = new JMenuItem("Help and Documentation");
    mntmDoc.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_H, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmDoc.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties,
                    AemDemoConstants.OPTIONS_DOCUMENTATION));
        }
    });
    mnAbout.add(mntmDoc);

    JMenuItem mntmQuit = new JMenuItem("Quit");
    mntmQuit.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmQuit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(-1);
        }
    });
    mnAbout.add(mntmQuit);

    JMenu mnNew = new JMenu("New");
    mnNew.setMnemonic(KeyEvent.VK_N);
    menuBar.add(mnNew);

    // New Demo Machine
    JMenuItem mntmNewDemo = new JMenuItem("Demo Environment");
    mntmNewDemo.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmNewDemo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if (AemDemo.this.getBuildInProgress()) {

                JOptionPane.showMessageDialog(null,
                        "A Demo Environment is currently being built. Please wait until it is finished.");

            } else {

                final AemDemoNew dialogNew = new AemDemoNew(AemDemo.this);
                dialogNew.setModal(true);
                dialogNew.setVisible(true);
                dialogNew.getDemoBuildName().requestFocus();
                ;

            }
        }
    });
    mnNew.add(mntmNewDemo);

    JMenuItem mntmNewOptions = new JMenuItem("Demo Properties");
    mntmNewOptions.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmNewOptions.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            final AemDemoOptions dialogOptions = new AemDemoOptions(AemDemo.this);
            dialogOptions.setModal(true);
            dialogOptions.setVisible(true);

        }
    });
    mnNew.add(mntmNewOptions);

    JMenu mnUpdate = new JMenu("Add-ons");
    menuBar.add(mnUpdate);

    // Sites Add-on
    JMenu mnSites = new JMenu("Sites");
    mnUpdate.add(mnSites);

    JMenuItem mntmSitesDownloadAddOn = new JMenuItem("Download Add-On");
    mntmSitesDownloadAddOn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_sites");
        }
    });
    mnSites.add(mntmSitesDownloadAddOn);

    JMenuItem mntmSitesDownloadFP = new JMenuItem("Download Feature Pack (VPN)");
    mntmSitesDownloadFP.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_sites_fp");
        }
    });
    mnSites.add(mntmSitesDownloadFP);

    mnSites.addSeparator();

    JMenuItem mntmSitesInstallAddOn = new JMenuItem("Install Add-on");
    mntmSitesInstallAddOn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "sites");
        }
    });
    mnSites.add(mntmSitesInstallAddOn);

    // Assets Add-on
    JMenu mnAssets = new JMenu("Assets");
    mnUpdate.add(mnAssets);

    JMenuItem mntmAssetsDownloadAddOn = new JMenuItem("Download Add-on");
    mntmAssetsDownloadAddOn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_assets");
        }
    });
    mnAssets.add(mntmAssetsDownloadAddOn);
    mnAssets.addSeparator();

    JMenuItem mntmAssetsInstallAddOn = new JMenuItem("Install Add-on");
    mntmAssetsInstallAddOn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "assets");
        }
    });
    mnAssets.add(mntmAssetsInstallAddOn);

    // Communities Add-on
    JMenu mnCommunities = new JMenu("Communities");
    mnUpdate.add(mnCommunities);

    JMenuItem mntmAemCommunitiesUber = new JMenuItem("Download Latest Bundles (VPN)");
    mntmAemCommunitiesUber.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_U, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmAemCommunitiesUber.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_communities_bundles");
        }
    });
    mnCommunities.add(mntmAemCommunitiesUber);

    JMenuItem mntmAemCommunitiesFeaturePacks = new JMenuItem("Download Latest Feature Packs (PackageShare)");
    mntmAemCommunitiesFeaturePacks.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_communities_fp");
        }
    });
    mnCommunities.add(mntmAemCommunitiesFeaturePacks);

    JMenuItem mntmAemCommunitiesEnablement = new JMenuItem("Download Enablement Demo Site Add-on (4.5GB)");
    mntmAemCommunitiesEnablement.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_enablement");
        }
    });
    mnCommunities.add(mntmAemCommunitiesEnablement);
    mnCommunities.addSeparator();

    JMenuItem mntmAemCommunitiesAddOn = new JMenuItem("Install Add-on");
    mntmAemCommunitiesAddOn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "communities");
        }
    });
    mnCommunities.add(mntmAemCommunitiesAddOn);

    // Forms Add-on
    JMenu mnForms = new JMenu("Forms");
    mnUpdate.add(mnForms);

    JMenuItem mntmAemFormsFP = new JMenuItem("Download Demo Add-on (PackageShare)");
    mntmAemFormsFP.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_forms_fp");
        }
    });
    mnForms.add(mntmAemFormsFP);

    mnForms.addSeparator();

    JMenuItem mntmAemFormsAddOn = new JMenuItem("Install Add-on");
    mntmAemFormsAddOn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "forms");
        }
    });
    mnForms.add(mntmAemFormsAddOn);

    // Apps Add-on
    JMenu mnApps = new JMenu("Apps");
    mnUpdate.add(mnApps);

    JMenuItem mntmAemApps = new JMenuItem("Download Add-on");
    mntmAemApps.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_apps");
        }
    });
    mnApps.add(mntmAemApps);

    mnApps.addSeparator();

    JMenuItem mntmAemAppsAddOn = new JMenuItem("Install Add-on");
    mntmAemAppsAddOn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "apps");
        }
    });
    mnApps.add(mntmAemAppsAddOn);

    // Commerce Add-on
    JMenu mnCommerce = new JMenu("Commerce");
    mnUpdate.add(mnCommerce);

    JMenu mnCommerceDownload = new JMenu("Download Add-on");
    mnCommerce.add(mnCommerceDownload);

    // Commerce EP
    JMenuItem mnCommerceDownloadEP = new JMenuItem("ElasticPath");
    mnCommerceDownloadEP.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_commerce_ep");
        }
    });
    mnCommerceDownload.add(mnCommerceDownloadEP);

    // Commerce WebSphere
    JMenuItem mnCommerceDownloadWAS = new JMenuItem("WebSphere");
    mnCommerceDownloadWAS.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_commerce_websphere");
        }
    });
    mnCommerceDownload.add(mnCommerceDownloadWAS);

    mnCommerce.addSeparator();

    JMenuItem mntmAemCommerceAddOn = new JMenuItem("Install Add-on");
    mntmAemCommerceAddOn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "commerce");
        }
    });
    mnCommerce.add(mntmAemCommerceAddOn);

    mnUpdate.addSeparator();

    JMenuItem mntmAemDownloadAll = new JMenuItem("Download All Add-ons");
    mntmAemDownloadAll.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_all");
        }
    });
    mnUpdate.add(mntmAemDownloadAll);

    JMenuItem mntmAemDownloadFromDrive = new JMenuItem("Download Web Page");
    mntmAemDownloadFromDrive.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties,
                    AemDemoConstants.OPTIONS_WEBDOWNLOAD));

        }
    });
    mnUpdate.add(mntmAemDownloadFromDrive);

    JMenu mnInfrastructure = new JMenu("Infrastructure");
    menuBar.add(mnInfrastructure);

    JMenu mnMongo = new JMenu("MongoDB");

    JMenuItem mntmInfraMongoDB = new JMenuItem("Download");
    mntmInfraMongoDB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_mongo");
        }
    });
    mnMongo.add(mntmInfraMongoDB);

    JMenuItem mntmInfraMongoDBInstall = new JMenuItem("Install");
    mntmInfraMongoDBInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "install_mongo");
        }
    });
    mnMongo.add(mntmInfraMongoDBInstall);
    mnMongo.addSeparator();

    JMenuItem mntmInfraMongoDBStart = new JMenuItem("Start");
    mntmInfraMongoDBStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "mongo_start");
        }
    });
    mnMongo.add(mntmInfraMongoDBStart);

    JMenuItem mntmInfraMongoDBStop = new JMenuItem("Stop");
    mntmInfraMongoDBStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "mongo_stop");
        }
    });
    mnMongo.add(mntmInfraMongoDBStop);
    mnInfrastructure.add(mnMongo);

    // SOLR options
    JMenu mnSOLR = new JMenu("SOLR");

    JMenuItem mntmInfraSOLR = new JMenuItem("Download");
    mntmInfraSOLR.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_solr");
        }
    });
    mnSOLR.add(mntmInfraSOLR);

    JMenuItem mntmInfraSOLRInstall = new JMenuItem("Install");
    mntmInfraSOLRInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "install_solr");
        }
    });
    mnSOLR.add(mntmInfraSOLRInstall);
    mnSOLR.addSeparator();

    JMenuItem mntmInfraSOLRStart = new JMenuItem("Start");
    mntmInfraSOLRStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "solr_start");
        }
    });
    mnSOLR.add(mntmInfraSOLRStart);

    JMenuItem mntmInfraSOLRStop = new JMenuItem("Stop");
    mntmInfraSOLRStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "solr_stop");
        }
    });
    mnSOLR.add(mntmInfraSOLRStop);

    mnInfrastructure.add(mnSOLR);

    // MySQL options
    JMenu mnMySQL = new JMenu("MySQL");

    JMenuItem mntmInfraMysql = new JMenuItem("Download");
    mntmInfraMysql.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_mysql");
        }
    });
    mnMySQL.add(mntmInfraMysql);

    JMenuItem mntmInfraMysqlInstall = new JMenuItem("Install");
    mntmInfraMysqlInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "install_mysql");
        }
    });
    mnMySQL.add(mntmInfraMysqlInstall);

    mnMySQL.addSeparator();

    JMenuItem mntmInfraMysqlStart = new JMenuItem("Start");
    mntmInfraMysqlStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "mysql_start");
        }
    });
    mnMySQL.add(mntmInfraMysqlStart);

    JMenuItem mntmInfraMysqlStop = new JMenuItem("Stop");
    mntmInfraMysqlStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "mysql_stop");
        }
    });
    mnMySQL.add(mntmInfraMysqlStop);

    mnInfrastructure.add(mnMySQL);

    // FFMPEPG options
    JMenu mnFFMPEG = new JMenu("FFMPEG");

    JMenuItem mntmInfraFFMPEG = new JMenuItem("Download");
    mntmInfraFFMPEG.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_ffmpeg");
        }
    });
    mnFFMPEG.add(mntmInfraFFMPEG);

    JMenuItem mntmInfraFFMPEGInstall = new JMenuItem("Install");
    mntmInfraFFMPEGInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "install_ffmpeg");
        }
    });
    mnFFMPEG.add(mntmInfraFFMPEGInstall);

    mnInfrastructure.add(mnFFMPEG);

    // Apache James options
    JMenu mnJames = new JMenu("James SMTP");

    JMenuItem mnJamesStart = new JMenuItem("Start");
    mnJamesStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "james_start");
        }
    });
    mnJames.add(mnJamesStart);

    JMenuItem mnJamesStop = new JMenuItem("Stop");
    mnJamesStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "james_stop");
        }
    });
    mnJames.add(mnJamesStop);

    mnInfrastructure.add(mnJames);

    mnInfrastructure.addSeparator();

    JMenuItem mntmInfraInstall = new JMenuItem("All in One Setup");
    mntmInfraInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "infrastructure");
        }
    });
    mnInfrastructure.add(mntmInfraInstall);

    JMenu mnOther = new JMenu("Other");
    menuBar.add(mnOther);

    JMenu mntmAemDownload = new JMenu("AEM & License files (VPN)");

    JMenuItem mntmAemDownloadAEM61 = new JMenuItem("Download AEM 6.1");
    mntmAemDownloadAEM61.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_aem61");
        }
    });
    mntmAemDownload.add(mntmAemDownloadAEM61);

    JMenuItem mntmAemDownloadAEM60 = new JMenuItem("Download AEM 6.0");
    mntmAemDownloadAEM60.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_aem60");
        }
    });
    mntmAemDownload.add(mntmAemDownloadAEM60);

    JMenuItem mntmAemDownloadCQ561 = new JMenuItem("Download CQ 5.6.1");
    mntmAemDownloadCQ561.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_cq561");
        }
    });
    mntmAemDownload.add(mntmAemDownloadCQ561);

    JMenuItem mntmAemDownloadCQ56 = new JMenuItem("Download CQ 5.6");
    mntmAemDownloadCQ56.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_cq56");
        }
    });
    mntmAemDownload.add(mntmAemDownloadCQ56);

    JMenuItem mntmAemDownloadOthers = new JMenuItem("Other Releases & License files");
    mntmAemDownloadOthers.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties,
                    AemDemoConstants.OPTIONS_DOWNLOAD));
        }
    });
    mntmAemDownload.add(mntmAemDownloadOthers);

    mnOther.add(mntmAemDownload);

    JMenuItem mntmAemSnapshot = new JMenuItem("Download Latest AEM Snapshot (VPN)");
    mntmAemSnapshot.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmAemSnapshot.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_snapshot");
        }
    });
    mnOther.add(mntmAemSnapshot);

    JMenuItem mntmAemDemoMachine = new JMenuItem("Download Latest AEM Demo Machine");
    mntmAemDemoMachine.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmAemDemoMachine.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties,
                    AemDemoConstants.OPTIONS_DEMODOWNLOAD));
        }
    });
    mnOther.add(mntmAemDemoMachine);

    // Adding the menu bar
    frameMain.setJMenuBar(menuBar);

    // Adding other form elements
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(24, 184, 650, 230);
    frameMain.getContentPane().add(scrollPane);

    final JTextArea textArea = new JTextArea("");
    textArea.setEditable(false);
    scrollPane.setViewportView(textArea);

    // List of demo machines available
    JScrollPane scrollDemoList = new JScrollPane();
    scrollDemoList.setBounds(24, 55, 208, 100);
    frameMain.getContentPane().add(scrollDemoList);
    listModelDemoMachines = AemDemoUtils.listDemoMachines(buildFile.getParentFile().getAbsolutePath());
    listDemoMachines = new JList(listModelDemoMachines);
    scrollDemoList.setViewportView(listDemoMachines);

    // Capturing the output stream of ANT commands
    AemDemoOutputStream out = new AemDemoOutputStream(textArea);
    System.setOut(new PrintStream(out));

    JButton btnStart = new JButton("Start");
    btnStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            AemDemoUtils.antTarget(AemDemo.this, "start");

        }
    });
    btnStart.setBounds(250, 50, 117, 29);
    frameMain.getContentPane().add(btnStart);

    // Set Start as the default button
    JRootPane rootPane = SwingUtilities.getRootPane(btnStart);
    rootPane.setDefaultButton(btnStart);

    JButton btnInfo = new JButton("Details");
    btnInfo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            AemDemoUtils.antTarget(AemDemo.this, "version");
            AemDemoUtils.antTarget(AemDemo.this, "configuration");

        }
    });
    btnInfo.setBounds(250, 80, 117, 29);
    frameMain.getContentPane().add(btnInfo);

    JButton btnStop = new JButton("Stop");
    btnStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            AemDemoUtils.antTarget(AemDemo.this, "stop");

        }
    });
    btnStop.setBounds(500, 50, 117, 29);
    frameMain.getContentPane().add(btnStop);

    JButton btnExit = new JButton("Exit");
    btnExit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(-1);
        }
    });
    btnExit.setBounds(550, 429, 117, 29);
    frameMain.getContentPane().add(btnExit);

    JButton btnClear = new JButton("Clear");
    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText("");
        }
    });
    btnClear.setBounds(40, 429, 117, 29);
    frameMain.getContentPane().add(btnClear);

    JButton btnBackup = new JButton("Backup");
    btnBackup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "backup");
        }
    });
    btnBackup.setBounds(500, 80, 117, 29);
    frameMain.getContentPane().add(btnBackup);

    JButton btnRestore = new JButton("Restore");
    btnRestore.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "restore");
        }
    });
    btnRestore.setBounds(500, 110, 117, 29);
    frameMain.getContentPane().add(btnRestore);

    JButton btnDelete = new JButton("Delete");
    btnDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "uninstall");
        }
    });
    btnDelete.setBounds(500, 140, 117, 29);
    frameMain.getContentPane().add(btnDelete);

    JLabel lblSelectYourDemo = new JLabel("Select your Demo Environment");
    lblSelectYourDemo.setBounds(24, 31, 219, 16);
    frameMain.getContentPane().add(lblSelectYourDemo);

    JLabel lblCommandOutput = new JLabel("Command Output");
    lblCommandOutput.setBounds(24, 164, 160, 16);
    frameMain.getContentPane().add(lblCommandOutput);

    // Launching the download tracker task
    AemDemoDownload aemDownload = new AemDemoDownload(AemDemo.this);
    ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
    executor.scheduleAtFixedRate(aemDownload, 0, 5, TimeUnit.SECONDS);

}

From source file:ee.ioc.cs.vsle.editor.Editor.java

/**
 * Build menu.// www .ja  v  a2  s  .c o  m
 */
public void makeMenu() {
    JMenuItem menuItem;

    JMenu menu;
    JMenu submenu;

    menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    menu = new JMenu(Menu.MENU_FILE);
    menu.setMnemonic(KeyEvent.VK_F);
    menuItem = new JMenuItem(Menu.NEW_SCHEME, KeyEvent.VK_N);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menu.addSeparator();
    menuItem = new JMenuItem(Menu.LOAD_SCHEME, KeyEvent.VK_O);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.RELOAD_SCHEME, KeyEvent.VK_R);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menu.addSeparator();
    menuItem = new JMenuItem(Menu.SAVE_SCHEME, KeyEvent.VK_S);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.SAVE_SCHEME_AS);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menu.add(menuItem);
    menu.addSeparator();
    menuItem = new JMenuItem(Menu.DELETE_SCHEME, KeyEvent.VK_D);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    submenu = new JMenu(Menu.EXPORT_MENU);
    menu.add(submenu);
    //submenu.setMnemonic( KeyEvent.VK_E );

    SchemeExporter.makeSchemeExportMenu(submenu, getActionListener());

    // Export window graphics
    submenu.add(GraphicsExporter.getExportMenu());

    menu.addSeparator();
    menuItem = new JMenuItem(Menu.PRINT, KeyEvent.VK_P);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menu.addSeparator();
    menuItem = new JMenuItem(Menu.EXIT, KeyEvent.VK_X);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuBar.add(menu);
    menu = new JMenu(Menu.MENU_EDIT);
    menu.setMnemonic(KeyEvent.VK_E);

    menu.add(undoAction);
    menu.add(redoAction);
    menu.add(cloneAction);

    menuItem = new JMenuItem(Menu.SCHEME_FIND, KeyEvent.VK_F);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK));
    menu.add(menuItem);

    menuItem = new JMenuItem(Menu.SELECT_ALL, KeyEvent.VK_A);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.CLEAR_ALL, KeyEvent.VK_C);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    final JCheckBoxMenuItem painterEnabled = new JCheckBoxMenuItem(Menu.CLASSPAINTER, true);
    painterEnabled.addActionListener(getActionListener());
    menu.add(painterEnabled);

    menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            Canvas canvas = Editor.getInstance().getCurrentCanvas();
            if (canvas == null || !canvas.getPackage().hasPainters()) {
                painterEnabled.setVisible(false);
            } else {
                painterEnabled.setVisible(true);
                painterEnabled.setSelected(canvas.isEnableClassPainter());
            }
        }

    });

    menuBar.add(menu);

    menu = new JMenu(Menu.MENU_VIEW);
    menu.setMnemonic(KeyEvent.VK_V);
    gridCheckBox = new JCheckBoxMenuItem(Menu.GRID, RuntimeProperties.isShowGrid());
    gridCheckBox.setMnemonic('G');
    gridCheckBox.addActionListener(getActionListener());
    menu.add(gridCheckBox);

    ctrlCheckBox = new JCheckBoxMenuItem(Menu.CONTROL_PANEL, RuntimeProperties.isShowControls());
    ctrlCheckBox.setMnemonic('C');
    ctrlCheckBox.addActionListener(getActionListener());
    menu.add(ctrlCheckBox);

    showPortCheckBox = new JCheckBoxMenuItem(Menu.SHOW_PORTS, true);
    showPortCheckBox.addActionListener(getActionListener());
    menu.add(showPortCheckBox);

    showObjectNamesCheckBox = new JCheckBoxMenuItem(Menu.SHOW_NAMES, false);
    showObjectNamesCheckBox.addActionListener(getActionListener());
    menu.add(showObjectNamesCheckBox);

    //sync View with current canvas
    menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            Canvas canvas;

            if ((canvas = getCurrentCanvas()) == null)
                return;

            gridCheckBox.setSelected(canvas.isGridVisible());
            ctrlCheckBox.setSelected(canvas.isCtrlPanelVisible());
            showPortCheckBox.setSelected(canvas.isDrawPorts());
            showObjectNamesCheckBox.setSelected(canvas.isShowObjectNames());
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // ignore
        }

    });

    menuBar.add(menu);

    menu = new JMenu(Menu.MENU_PACKAGE);
    menu.setMnemonic(KeyEvent.VK_P);
    menuItem = new JMenuItem(Menu.LOAD, KeyEvent.VK_L);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.RELOAD, KeyEvent.VK_R);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.INFO, KeyEvent.VK_I);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    if (Desktop.isDesktopSupported()) {
        menuItem = new JMenuItem(Menu.BROWSE_PACKAGE, KeyEvent.VK_B);
        menuItem.addActionListener(getActionListener());
        menu.add(menuItem);
    }
    menuItem = new JMenuItem(Menu.CLOSE, KeyEvent.VK_C);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.CLOSE_ALL);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuBar.add(menu);
    menu.add(new JSeparator());
    final JMenu submenuRecent = new JMenu(Menu.RECENT);
    submenuRecent.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {

        final JMenuItem empty = new JMenuItem("Empty");

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {

            makeRecentSubMenu(submenuRecent);

            if (submenuRecent.getMenuComponentCount() == 0) {

                submenuRecent.add(empty);
                empty.setEnabled(false);

            } else {
                if (!((submenuRecent.getMenuComponentCount() == 1)
                        && (submenuRecent.getPopupMenu().getComponentIndex(empty) >= -1))) {
                    submenuRecent.remove(empty);
                }
            }

        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // ignore
        }

    });
    menu.add(submenuRecent);
    final JMenu menuScheme = new JMenu(Menu.MENU_SCHEME);
    menuScheme.setMnemonic(KeyEvent.VK_S);
    makeSchemeMenu(menuScheme);

    menuScheme.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {

            makeSchemeMenu(menuScheme);

        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // ignore
        }

    });

    /*
     * menuItem = new JMenuItem("Planner");
     * menuItem.addActionListener(aListener); menuScheme.add(menuItem);
     * menuItem = new JMenuItem("Plan, compile, run");
     * menuItem.setActionCommand("Run");
     * menuItem.addActionListener(aListener); menuScheme.add(menuItem);
     */
    // menuScheme.setMnemonic(KeyEvent.VK_A);
    menuBar.add(menuScheme);
    menu = new JMenu(Menu.MENU_OPTIONS);
    menu.setMnemonic(KeyEvent.VK_O);

    menuItem = new JMenuItem(Menu.SETTINGS, KeyEvent.VK_S);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, ActionEvent.CTRL_MASK));
    menu.add(menuItem);

    menuItem = new JMenuItem(Menu.FONTS);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    menuItem = new JMenuItem(Menu.SAVE_SETTINGS);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    submenu = new JMenu(Menu.MENU_LAF);
    submenu.setMnemonic(KeyEvent.VK_L);
    Look.getInstance().createMenuItems(submenu);
    menu.add(submenu);
    menuBar.add(menu);

    makeToolsMenu(menuBar);

    menu = new JMenu(Menu.MENU_HELP);
    menu.setMnemonic(KeyEvent.VK_H);
    menuBar.add(menu);
    menuItem = new JMenuItem(Menu.DOCS, KeyEvent.VK_D);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
}

From source file:net.sf.firemox.DeckBuilder.java

/**
 * Creates new form DeckBuilder/*from w w w .  j a  v a  2 s.c  o  m*/
 */
private DeckBuilder() {
    super("DeckBuilder");
    form = this;
    timerPanel = new TimerGlassPane();
    cardLoader = new CardLoader(timerPanel);
    timer = new Timer(200, cardLoader);
    setGlassPane(timerPanel);
    try {
        setIconImage(Picture.loadImage(IdConst.IMAGES_DIR + "deckbuilder.gif"));
    } catch (Exception e) {
        // IGNORING
    }

    // Load settings
    loadSettings();

    // Initialize components
    final JMenuItem newItem = UIHelper.buildMenu("menu_db_new", 'n', this);
    newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));

    final JMenuItem loadItem = UIHelper.buildMenu("menu_db_load", 'o', this);
    loadItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));

    final JMenuItem saveAsItem = UIHelper.buildMenu("menu_db_saveas", 'a', this);
    saveAsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0));

    final JMenuItem saveItem = UIHelper.buildMenu("menu_db_save", 's', this);
    saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));

    final JMenuItem quitItem = UIHelper.buildMenu("menu_db_exit", this);
    quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK));

    final JMenuItem deckConstraintsItem = UIHelper.buildMenu("menu_db_constraints", 'c', this);
    deckConstraintsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));

    final JMenuItem aboutItem = UIHelper.buildMenu("menu_help_about", 'a', this);
    aboutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.SHIFT_MASK));

    final JMenuItem convertDCK = UIHelper.buildMenu("menu_convert_DCK_MP", this);

    final JMenu mainMenu = UIHelper.buildMenu("menu_file");
    mainMenu.add(newItem);
    mainMenu.add(loadItem);
    mainMenu.add(saveAsItem);
    mainMenu.add(saveItem);
    mainMenu.add(new JSeparator());
    mainMenu.add(quitItem);

    super.optionMenu = new JMenu("Options");

    final JMenu convertMenu = UIHelper.buildMenu("menu_convert");
    convertMenu.add(convertDCK);

    final JMenuItem helpItem = UIHelper.buildMenu("menu_help_help", 'h', this);
    helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));

    final JMenu helpMenu = new JMenu("?");
    helpMenu.add(helpItem);
    helpMenu.add(deckConstraintsItem);
    helpMenu.add(aboutItem);

    final JMenuBar menuBar = new JMenuBar();
    menuBar.add(mainMenu);
    initAbstractMenu();
    menuBar.add(optionMenu);
    menuBar.add(convertMenu);
    menuBar.add(helpMenu);
    setJMenuBar(menuBar);
    addWindowListener(this);

    // Build the panel containing amount of available cards
    final JLabel amountLeft = new JLabel("<html>0/?", SwingConstants.RIGHT);

    // Build the left list
    allListModel = new MListModel<MCardCompare>(amountLeft, false);
    leftList = new ThreadSafeJList(allListModel);
    leftList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    leftList.setLayoutOrientation(JList.VERTICAL);
    leftList.getSelectionModel().addListSelectionListener(this);
    leftList.addMouseListener(this);
    leftList.setVisibleRowCount(10);

    // Initialize the text field containing the amount to add
    addQtyTxt = new JTextField("1");

    // Build the "Add" button
    addButton = new JButton(LanguageManager.getString("db_add"));
    addButton.setMnemonic('a');
    addButton.setEnabled(false);

    // Build the panel containing : "Add" amount and "Add" button
    final Box addPanel = Box.createHorizontalBox();
    addPanel.add(addButton);
    addPanel.add(addQtyTxt);
    addPanel.setMaximumSize(new Dimension(32010, 26));

    // Build the panel containing the selected card name
    cardNameTxt = new JTextField();
    new HireListener(cardNameTxt, addButton, this, leftList);

    final JLabel searchLabel = new JLabel(LanguageManager.getString("db_search") + " : ");
    searchLabel.setLabelFor(cardNameTxt);

    // Build the panel containing search label and card name text field
    final Box searchPanel = Box.createHorizontalBox();
    searchPanel.add(searchLabel);
    searchPanel.add(cardNameTxt);
    searchPanel.setMaximumSize(new Dimension(32010, 26));

    listScrollerLeft = new JScrollPane(leftList);
    MToolKit.addOverlay(listScrollerLeft);

    // Build the left panel containing : list, available amount, "Add" panel
    final JPanel srcPanel = new JPanel(null);
    srcPanel.add(searchPanel);
    srcPanel.add(listScrollerLeft);
    srcPanel.add(amountLeft);
    srcPanel.add(addPanel);
    srcPanel.setMinimumSize(new Dimension(220, 200));
    srcPanel.setLayout(new BoxLayout(srcPanel, BoxLayout.Y_AXIS));

    // Initialize constraints
    constraintsChecker = new ConstraintsChecker();
    constraintsChecker.setBorder(new EtchedBorder());
    final JScrollPane constraintsCheckerScroll = new JScrollPane(constraintsChecker);
    MToolKit.addOverlay(constraintsCheckerScroll);

    // create a pane with the oracle text for the present card
    oracleText = new JLabel();
    oracleText.setPreferredSize(new Dimension(180, 200));
    oracleText.setVerticalAlignment(SwingConstants.TOP);

    final JScrollPane oracle = new JScrollPane(oracleText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    MToolKit.addOverlay(oracle);

    // build some Pie Charts and a panel to display it
    initSets();
    datasets = new ChartSets();
    final JTabbedPane tabbedPane = new JTabbedPane();
    for (ChartFilter filter : ChartFilter.values()) {
        final Dataset dataSet = filter.createDataSet(this);
        final JFreeChart chart = new JFreeChart(null, null,
                filter.createPlot(dataSet, painterMapper.get(filter)), false);
        datasets.addDataSet(filter, dataSet);
        ChartPanel pieChartPanel = new ChartPanel(chart, true);
        tabbedPane.add(pieChartPanel, filter.getTitle());
    }
    // add the Constraints scroll panel and Oracle text Pane to the tabbedPane
    tabbedPane.add(constraintsCheckerScroll, LanguageManager.getString("db_constraints"));
    tabbedPane.add(oracle, LanguageManager.getString("db_text"));
    tabbedPane.setSelectedComponent(oracle);

    // The toollBar for color filtering
    toolBar = new JToolBar();
    toolBar.setFloatable(false);
    final JButton clearButton = UIHelper.buildButton("clear");
    clearButton.addActionListener(this);
    toolBar.add(clearButton);
    final JToggleButton toggleColorlessButton = new JToggleButton(
            UIHelper.getTbsIcon("mana/colorless/small/" + MdbLoader.unknownSmlMana), true);
    toggleColorlessButton.setActionCommand("0");
    toggleColorlessButton.addActionListener(this);
    toolBar.add(toggleColorlessButton);
    for (int index = 1; index < IdCardColors.CARD_COLOR_NAMES.length; index++) {
        final JToggleButton toggleButton = new JToggleButton(
                UIHelper.getTbsIcon("mana/colored/small/" + MdbLoader.coloredSmlManas[index]), true);
        toggleButton.setActionCommand(String.valueOf(index));
        toggleButton.addActionListener(this);
        toolBar.add(toggleButton);
    }

    // sorted card type combobox creation
    final List<String> idCards = new ArrayList<String>(Arrays.asList(CardFactory.exportedIdCardNames));
    Collections.sort(idCards);
    final Object[] cardTypes = ArrayUtils.addAll(new String[] { LanguageManager.getString("db_types.any") },
            idCards.toArray());
    idCardComboBox = new JComboBox(cardTypes);
    idCardComboBox.setSelectedIndex(0);
    idCardComboBox.addActionListener(this);
    idCardComboBox.setActionCommand("cardTypeFilter");

    // sorted card properties combobox creation
    final List<String> properties = new ArrayList<String>(
            CardFactory.getPropertiesName(DeckConstraints.getMinProperty(), DeckConstraints.getMaxProperty()));
    Collections.sort(properties);
    final Object[] cardProperties = ArrayUtils
            .addAll(new String[] { LanguageManager.getString("db_properties.any") }, properties.toArray());
    propertiesComboBox = new JComboBox(cardProperties);
    propertiesComboBox.setSelectedIndex(0);
    propertiesComboBox.addActionListener(this);
    propertiesComboBox.setActionCommand("propertyFilter");

    final JLabel colors = new JLabel(" " + LanguageManager.getString("colors") + " : ");
    final JLabel types = new JLabel(" " + LanguageManager.getString("types") + " : ");
    final JLabel property = new JLabel(" " + LanguageManager.getString("properties") + " : ");

    // filter Panel with colors toolBar and card type combobox
    final Box filterPanel = Box.createHorizontalBox();
    filterPanel.add(colors);
    filterPanel.add(toolBar);
    filterPanel.add(types);
    filterPanel.add(idCardComboBox);
    filterPanel.add(property);
    filterPanel.add(propertiesComboBox);

    getContentPane().add(filterPanel, BorderLayout.NORTH);

    // Destination section :

    // Build the panel containing amount of available cards
    final JLabel rightAmount = new JLabel("0/?", SwingConstants.RIGHT);
    rightAmount.setMaximumSize(new Dimension(220, 26));

    // Build the right list
    rightListModel = new MCardTableModel(new MListModel<MCardCompare>(rightAmount, true));
    rightListModel.addTableModelListener(this);
    rightList = new JTable(rightListModel);
    rightList.setShowGrid(false);
    rightList.setTableHeader(null);
    rightList.getSelectionModel().addListSelectionListener(this);
    rightList.getColumnModel().getColumn(0).setMaxWidth(25);
    rightList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    // Build the panel containing the selected deck
    deckNameTxt = new JTextField("loading...");
    deckNameTxt.setEditable(false);
    deckNameTxt.setBorder(null);
    final JLabel deckLabel = new JLabel(LanguageManager.getString("db_deck") + " : ");
    deckLabel.setLabelFor(deckNameTxt);
    final Box deckNamePanel = Box.createHorizontalBox();
    deckNamePanel.add(deckLabel);
    deckNamePanel.add(deckNameTxt);
    deckNamePanel.setMaximumSize(new Dimension(220, 26));

    // Initialize the text field containing the amount to remove
    removeQtyTxt = new JTextField("1");

    // Build the "Remove" button
    removeButton = new JButton(LanguageManager.getString("db_remove"));
    removeButton.setMnemonic('r');
    removeButton.addMouseListener(this);
    removeButton.setEnabled(false);

    // Build the panel containing : "Remove" amount and "Remove" button
    final Box removePanel = Box.createHorizontalBox();
    removePanel.add(removeButton);
    removePanel.add(removeQtyTxt);
    removePanel.setMaximumSize(new Dimension(220, 26));

    // Build the right panel containing : list, available amount, constraints
    final JScrollPane deskListScroller = new JScrollPane(rightList);
    MToolKit.addOverlay(deskListScroller);
    deskListScroller.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    deskListScroller.setMinimumSize(new Dimension(220, 200));
    deskListScroller.setMaximumSize(new Dimension(220, 32000));

    final Box destPanel = Box.createVerticalBox();
    destPanel.add(deckNamePanel);
    destPanel.add(deskListScroller);
    destPanel.add(rightAmount);
    destPanel.add(removePanel);
    destPanel.setMinimumSize(new Dimension(220, 200));
    destPanel.setMaximumSize(new Dimension(220, 32000));

    // Build the panel containing the name of card in picture
    cardPictureNameTxt = new JLabel("<html><i>no selected card</i>");
    final Box cardPictureNamePanel = Box.createHorizontalBox();
    cardPictureNamePanel.add(cardPictureNameTxt);
    cardPictureNamePanel.setMaximumSize(new Dimension(32010, 26));

    // Group the detail panels
    final JPanel viewCard = new JPanel(null);
    viewCard.add(cardPictureNamePanel);
    viewCard.add(CardView.getInstance());
    viewCard.add(tabbedPane);
    viewCard.setLayout(new BoxLayout(viewCard, BoxLayout.Y_AXIS));

    final Box mainPanel = Box.createHorizontalBox();
    mainPanel.add(destPanel);
    mainPanel.add(viewCard);

    // Add the main panel
    getContentPane().add(srcPanel, BorderLayout.WEST);
    getContentPane().add(mainPanel, BorderLayout.CENTER);

    // Size this frame
    getRootPane().setPreferredSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT));
    getRootPane().setMinimumSize(getRootPane().getPreferredSize());
    pack();
}

From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java

/**
 * Setups the Menu Bar//  w  w  w  . j  a v  a 2s  . c  o m
 * @return
 */
private JMenuBar setupMenu() {
    JMenuBar menuBar = new JMenuBar();

    /* -- Cluster Menu -- */
    JMenu clusterMenu = new JMenu("Cluster");
    clusterMenu.setMnemonic(KeyEvent.VK_C);
    menuBar.add(clusterMenu);

    // Discover Submenu
    JMenu clusterDiscoverMenu = new JMenu("Disover Peers");
    clusterDiscoverMenu.setMnemonic(KeyEvent.VK_D);
    clusterMenu.add(clusterDiscoverMenu);

    // Discover -> Multicast
    JMenuItem clusterDiscoverMulticast = new JMenuItem("Multicast");
    clusterDiscoverMulticast.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0));
    clusterDiscoverMulticast.setEnabled(false);
    clusterDiscoverMulticast.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doDiscoverMulticast();
        }
    });
    clusterDiscoverMenu.add(clusterDiscoverMulticast);
    addUIElement("menu.cluster.discover.multicast", clusterDiscoverMulticast); // Add to components map

    // Discover -> WS
    JMenuItem clusterDiscoverWS = new JMenuItem("Colombus Web Service");
    clusterDiscoverWS.setEnabled(false);
    clusterDiscoverWS.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0));
    clusterDiscoverWS.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doDiscoverWS();
        }
    });
    clusterDiscoverMenu.add(clusterDiscoverWS);
    addUIElement("menu.cluster.discover.ws", clusterDiscoverWS); // Add to components map

    clusterMenu.addSeparator();

    // Cluster-> Shutdown
    JMenuItem clusterShutdownItem = new JMenuItem("Shutdown", 'u');
    clusterShutdownItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0));
    clusterShutdownItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doShutdownCluster();
        }
    });
    clusterMenu.add(clusterShutdownItem);
    addUIElement("menu.cluster.shutdown", clusterShutdownItem); // Add to components map

    /* -- Options Menu -- */
    JMenu optionsMenu = new JMenu("Options");
    optionsMenu.setMnemonic(KeyEvent.VK_O);
    menuBar.add(optionsMenu);

    // Configuration
    JMenuItem optionsConfigItem = new JMenuItem("Configuration...", 'C');
    optionsConfigItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showConfiguration();
        }
    });
    optionsMenu.add(optionsConfigItem);
    optionsConfigItem.setEnabled(false); // TODO Create Configuration Options

    /* -- Help Menu -- */
    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic(KeyEvent.VK_H);
    menuBar.add(helpMenu);

    // Help Contents
    JMenuItem helpContentsItem = new JMenuItem("Help Contents", 'H');
    helpContentsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
    helpContentsItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showHelp();
        }
    });
    helpMenu.add(helpContentsItem);

    helpMenu.addSeparator();

    JMenuItem helpAboutItem = new JMenuItem("About", 'A');
    helpAboutItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showAbout();
        }
    });
    helpMenu.add(helpAboutItem);

    return menuBar;
}

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

private void initFileMenu(JMenu mnFile) {
    mnFile.removeAll();/*  w  ww. jav  a  2  s . c  o  m*/

    // 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:com.opendoorlogistics.studio.AppFrame.java

private void initMenus() {
    final JMenuBar menuBar = new JMenuBar();
    class AddSpace {
        void add() {
            JMenu dummy = new JMenu();
            dummy.setEnabled(false);//from   w w w.j  a  va  2  s . co m
            menuBar.add(dummy);
        }
    }
    AddSpace addSpace = new AddSpace();

    // add file menu ... build on the fly for recent files..
    setJMenuBar(menuBar);
    final JMenu mnFile = new JMenu("File");
    mnFile.setMnemonic('F');
    mnFile.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(MenuEvent e) {
            initFileMenu(mnFile);
        }

        @Override
        public void menuDeselected(MenuEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void menuCanceled(MenuEvent e) {
            // TODO Auto-generated method stub

        }
    });
    initFileMenu(mnFile);
    menuBar.add(mnFile);
    addSpace.add();

    // add edit menu
    JMenu mnEdit = new JMenu("Edit");
    mnEdit.setMnemonic('E');
    menuBar.add(mnEdit);
    addSpace.add();
    for (MyAction action : editActions) {
        JMenuItem item = mnEdit.add(action);
        if (action.accelerator != null) {
            item.setAccelerator(action.accelerator);
        }
    }

    // add run scripts menu (hidden until a datastore is loaded)
    mnScripts = new JMenu("Run script");
    mnScripts.setMnemonic('R');
    mnScripts.setVisible(false);
    mnScripts.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(MenuEvent e) {
            mnScripts.removeAll();
            for (final ScriptNode item : scriptsPanel.getScripts()) {
                if (item.isAvailable() == false) {
                    continue;
                }
                if (item.isRunnable()) {
                    mnScripts.add(new AbstractAction(item.getDisplayName(), item.getIcon()) {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            scriptManager.executeScript(item.getFile(), item.getLaunchExecutorId());
                        }
                    });
                } else if (item.getChildCount() > 0) {
                    JMenu popup = new JMenu(item.getDisplayName());
                    mnScripts.add(popup);
                    for (int i = 0; i < item.getChildCount(); i++) {
                        final ScriptNode child = (ScriptNode) item.getChildAt(i);
                        if (child.isRunnable()) {
                            popup.add(new AbstractAction(child.getDisplayName(), child.getIcon()) {

                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    scriptManager.executeScript(child.getFile(), child.getLaunchExecutorId());
                                }
                            });
                        }

                    }
                }
            }
            mnScripts.validate();
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });
    menuBar.add(mnScripts);
    addSpace.add();

    // add create script menu
    menuBar.add(initCreateScriptsMenu());
    addSpace.add();

    // add window menu
    JMenu mnWindow = new JMenu("Window");
    mnWindow.setMnemonic('W');
    menuBar.add(mnWindow);
    addSpace.add();
    initWindowMenus(mnWindow);

    menuBar.add(initHelpMenu());

    addSpace.add();

}

From source file:SciTK.Plot.java

/** 
 * Load the initial UI/*from  w w  w  .j  av  a2 s.co  m*/
 */
protected final void initUI() {
    setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

    // create a ChartPanel, and make it default to 1/4 of screen size:
    chart_panel = new ChartPanel(chart);
    chart_panel.setPreferredSize(new Dimension(def_width, def_height));

    //add the chart to the window:
    getContentPane().add(chart_panel);

    // create a menu bar:
    menubar = new JMenuBar();
    // ---------------------------------------------------------
    //                 First dropdown menu: "File"
    // ---------------------------------------------------------
    file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);

    // Set up a save dialog option under the file menu:
    JMenuItem menu_file_save;
    ImageIcon menu_file_save_icon = null;
    try {
        menu_file_save_icon = new ImageIcon(getClass().getResource("/SciTK/resources/document-save-5.png"));
        menu_file_save = new JMenuItem("Save", menu_file_save_icon);
    } catch (Exception e) {
        menu_file_save = new JMenuItem("Save");
    }
    menu_file_save.setMnemonic(KeyEvent.VK_S);
    menu_file_save.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu_file_save.setToolTipText("Save an image");
    menu_file_save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            saveImage();
        }
    });
    file.add(menu_file_save);

    // Set up a save SVG dialog option under the file menu:
    JMenuItem menu_file_save_svg;
    try {
        menu_file_save_svg = new JMenuItem("Save VG", menu_file_save_icon);
    } catch (Exception e) {
        menu_file_save_svg = new JMenuItem("Save VG");
    }
    menu_file_save_svg.setToolTipText("Save as vector graphics (SVG,PS,EPS)");
    menu_file_save_svg.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            saveVectorGraphics();
        }
    });
    file.add(menu_file_save_svg);

    // Set up a save data dialog option under the file menu:
    JMenuItem menu_file_save_data;
    try {
        menu_file_save_data = new JMenuItem("Save data", menu_file_save_icon);
    } catch (Exception e) {
        menu_file_save_data = new JMenuItem("Save data");
    }
    menu_file_save_data.setToolTipText("Save raw data to file");
    menu_file_save_data.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            saveData();
        }
    });
    file.add(menu_file_save_data);

    // Set up a save data dialog option under the file menu:
    JMenuItem menu_file_print;
    try {
        ImageIcon menu_file_print_icon = new ImageIcon(
                getClass().getResource("/SciTK/resources/document-print-5.png"));
        menu_file_print = new JMenuItem("Print", menu_file_print_icon);
    } catch (Exception e) {
        menu_file_print = new JMenuItem("Print");
    }
    menu_file_print.setToolTipText("Print image of chart");
    menu_file_print.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            printPlot();
        }
    });
    file.add(menu_file_print);

    // menu item for exiting
    JMenuItem menu_file_exit;
    try {
        ImageIcon menu_file_exit_icon = new ImageIcon(
                getClass().getResource("/SciTK/resources/application-exit.png"));
        menu_file_exit = new JMenuItem("Exit", menu_file_exit_icon);
    } catch (Exception e) {
        menu_file_exit = new JMenuItem("Exit");
    }
    menu_file_exit.setMnemonic(KeyEvent.VK_X);
    menu_file_exit.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu_file_exit.setToolTipText("Exit application");
    menu_file_exit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dispose();
        }

    });
    file.add(menu_file_exit);

    // ---------------------------------------------------------
    //                 Second dropdown menu: "Edit"
    // ---------------------------------------------------------
    edit = new JMenu("Edit");
    edit.setMnemonic(KeyEvent.VK_E);

    // copy to clipboard
    JMenuItem menu_edit_copy_image;
    ImageIcon menu_edit_copy_icon = null;
    try {
        menu_edit_copy_icon = new ImageIcon(getClass().getResource("/SciTK/resources/edit-copy-7.png"));
        menu_edit_copy_image = new JMenuItem("Copy", menu_edit_copy_icon);
    } catch (Exception e) {
        menu_edit_copy_image = new JMenuItem("Copy");
    }
    menu_edit_copy_image.setMnemonic(KeyEvent.VK_C);
    menu_edit_copy_image.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu_edit_copy_image.setToolTipText("Copy image to clipboard");
    menu_edit_copy_image.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            copyImage();
        }
    });
    edit.add(menu_edit_copy_image);

    // copy data to clipboard
    JMenuItem menu_edit_copy_data;
    try {
        menu_edit_copy_data = new JMenuItem("Copy data", menu_edit_copy_icon);
    } catch (Exception e) {
        menu_edit_copy_data = new JMenuItem("Copy data");
    }
    menu_edit_copy_data.setToolTipText("Copy data to clipboard");
    menu_edit_copy_data.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            copyData();
        }
    });
    edit.add(menu_edit_copy_data);

    // set background color
    JMenuItem menu_edit_BackgroundColor;
    ImageIcon menu_edit_Color_icon = null;
    try {
        menu_edit_Color_icon = new ImageIcon(getClass().getResource("/SciTK/resources/color-wheel.png"));
        menu_edit_BackgroundColor = new JMenuItem("Background Color", menu_edit_Color_icon);
    } catch (Exception e) {
        menu_edit_BackgroundColor = new JMenuItem("Background Color");
    }
    menu_edit_BackgroundColor.setToolTipText("Select background color");
    menu_edit_BackgroundColor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Color bgColor = plotColorChooser("Choose background color", (Color) chart.getBackgroundPaint());
            setBackgroundColor(bgColor);
        }
    });
    edit.add(menu_edit_BackgroundColor);

    // set plot color
    JMenuItem menu_edit_PlotColor;
    try {
        menu_edit_PlotColor = new JMenuItem("Window Color", menu_edit_Color_icon);
    } catch (Exception e) {
        menu_edit_PlotColor = new JMenuItem("Window Color");
    }
    menu_edit_PlotColor.setToolTipText("Select plot window color");
    menu_edit_PlotColor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Color plotColor = plotColorChooser("Choose plot color",
                    (Color) chart.getPlot().getBackgroundPaint());
            setWindowBackground(plotColor);
        }
    });
    edit.add(menu_edit_PlotColor);

    // set gridline color
    JMenuItem menu_edit_GridlineColor;
    try {
        menu_edit_GridlineColor = new JMenuItem("Gridline Color", menu_edit_Color_icon);
    } catch (Exception e) {
        menu_edit_GridlineColor = new JMenuItem("Gridline Color");
    }
    menu_edit_GridlineColor.setToolTipText("Select grid color");
    menu_edit_GridlineColor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Color gridColor = plotColorChooser("Choose grid color",
                    (Color) chart.getPlot().getBackgroundPaint());
            setGridlineColor(gridColor);
        }
    });
    edit.add(menu_edit_GridlineColor);

    // edit chart preferences
    JMenuItem menu_edit_preferences;
    try {
        ImageIcon menu_edit_preferences_icon = new ImageIcon(
                getClass().getResource("/SciTK/resources/preferences-desktop-3.png"));
        menu_edit_preferences = new JMenuItem("Preferences", menu_edit_preferences_icon);
    } catch (Exception e) {
        menu_edit_preferences = new JMenuItem("Preferences");
    }
    menu_edit_preferences.setToolTipText("Edit chart preferences");
    menu_edit_preferences.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            chart_panel.doEditChartProperties();
        }
    });
    edit.add(menu_edit_preferences);

    // ---------------------------------------------------------
    //                 Third dropdown menu: "Plot"
    // ---------------------------------------------------------
    plot = new JMenu("Plot");
    plot.setMnemonic(KeyEvent.VK_P);

    // Options to set log axes
    JCheckBoxMenuItem menu_plot_ylog = new JCheckBoxMenuItem("Log y axis");
    menu_plot_ylog.setToolTipText("Set y axis to logarithmic");
    menu_plot_ylog.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setRangeAxisLog(selected);
        }
    });
    plot.add(menu_plot_ylog);

    JCheckBoxMenuItem menu_plot_xlog = new JCheckBoxMenuItem("Log x axis");
    menu_plot_xlog.setToolTipText("Set x axis to logarithmic");
    menu_plot_xlog.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setDomainAxisLog(selected);
        }
    });
    plot.add(menu_plot_xlog);

    // grid line display
    JCheckBoxMenuItem menu_plot_grid = new JCheckBoxMenuItem("Grid lines");
    menu_plot_grid.setToolTipText("Show plot grid lines?");
    menu_plot_grid.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setGridlineVisible(selected);
        }
    });
    // set appropirate checkbox state:
    menu_plot_grid.setState(chart.getXYPlot().isDomainGridlinesVisible());
    plot.add(menu_plot_grid);

    // control for displaying plot legend
    JCheckBoxMenuItem menu_plot_legend = new JCheckBoxMenuItem("Legend");
    menu_plot_legend.setToolTipText("Show plot legend?");
    menu_plot_legend.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setLegend(selected);
        }
    });
    // set appropirate checkbox state:
    menu_plot_legend.setState((chart.getLegend() instanceof LegendTitle));
    plot.add(menu_plot_legend);

    // ---------------------------------------------------------
    //                 General UI
    // ---------------------------------------------------------
    // Add menus to the menu bar:
    menubar.add(file);
    menubar.add(edit);
    menubar.add(plot);
    // Set menubar as this JFrame's menu
    setJMenuBar(menubar);

    // set default plot colors:
    chart.setBackgroundPaint(new Color(255, 255, 255, 0));
    chart.getPlot().setBackgroundPaint(new Color(255, 255, 255, 255));
    setBackgroundAlpha(0.0f);

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    pack();
    setTitle(window_title);
    setLocationRelativeTo(null);
    setVisible(true);
}

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

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

    menuBar.setBackground(parentFrame.corDefault);

    JMenu menuArquivo = new JMenu(GERAL.ARQUIVO);
    menuArquivo.setMnemonic('A');
    menuArquivo.setMnemonic(KeyEvent.VK_A);
    menuArquivo.setBackground(parentFrame.corDefault);

    JMenu avaliadores = new JMenu();
    MenuSilvinha menuSilvinha = new MenuSilvinha(parentFrame, null);
    menuSilvinha.criaMenuAvaliadores(avaliadores);
    // menuArquivo.add(avaliadores);
    // menuArquivo.add(new JSeparator());

    JMenuItem btnAbrir = new JMenuItem(GERAL.BTN_ABRIR);
    btnAbrir.addActionListener(this);
    btnAbrir.setActionCommand("Abrir");
    btnAbrir.setMnemonic('A');
    btnAbrir.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    btnAbrir.setMnemonic(KeyEvent.VK_A);
    btnAbrir.setToolTipText(GERAL.DICA_ABRIR);
    btnAbrir.getAccessibleContext().setAccessibleDescription(GERAL.DICA_ABRIR);
    menuArquivo.add(btnAbrir);/*from ww  w  .  ja v  a2 s  . co m*/

    JMenuItem btnAbrirUrl = new JMenuItem(br.org.acessobrasil.silvinha2.mli.XHTML_Panel.BTN_ABRIR_URL);
    btnAbrirUrl.addActionListener(this);
    btnAbrirUrl.setActionCommand("AbrirURL");
    btnAbrirUrl.setMnemonic('U');
    btnAbrirUrl.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, ActionEvent.CTRL_MASK));
    btnAbrirUrl.setMnemonic(KeyEvent.VK_U);
    btnAbrirUrl.setToolTipText(br.org.acessobrasil.silvinha2.mli.XHTML_Panel.DICA_ABRIR);
    btnAbrirUrl.getAccessibleContext()
            .setAccessibleDescription(br.org.acessobrasil.silvinha2.mli.XHTML_Panel.DICA_ABRIR);
    menuArquivo.add(btnAbrirUrl);

    btnSalvar = new JMenuItem(GERAL.BTN_SALVAR);
    btnSalvar.addActionListener(this);
    btnSalvar.setActionCommand("Salvar");
    btnSalvar.setMnemonic('S');
    btnSalvar.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    btnSalvar.setMnemonic(KeyEvent.VK_S);
    btnSalvar.getAccessibleContext().setAccessibleDescription(GERAL.SALVA_REAVALIA);
    menuArquivo.add(btnSalvar);

    JMenuItem btnSalvarAs = new JMenuItem(GERAL.BTN_SALVAR_COMO);
    btnSalvarAs.addActionListener(this);
    btnSalvarAs.setActionCommand("SaveAs");
    btnSalvarAs.setMnemonic('c');
    btnSalvarAs.setMnemonic(KeyEvent.VK_C);
    // btnSalvarAs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N,
    // ActionEvent.CTRL_MASK));
    btnSalvarAs.setToolTipText(GERAL.DICA_SALVAR_COMO);
    btnSalvarAs.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SALVAR_COMO);
    menuArquivo.add(btnSalvarAs);

    menuArquivo.add(new JSeparator());

    JMenuItem btnFechar = new JMenuItem(GERAL.SAIR);
    btnFechar.addActionListener(this);
    btnFechar.setActionCommand("Sair");
    btnFechar.setMnemonic('a');
    btnFechar.setMnemonic(KeyEvent.VK_A);
    btnFechar.setToolTipText(GERAL.DICA_SAIR);
    btnFechar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SAIR);
    menuArquivo.add(btnFechar);

    menuBar.add(menuArquivo);

    menuBar.add(this.criaMenuEditar());

    menuBar.add(avaliadores);

    JMenu menuSimuladores = new JMenu();
    menuSilvinha.criaMenuSimuladores(menuSimuladores);
    menuBar.add(menuSimuladores);

    JMenu mnFerramenta = new JMenu();
    menuSilvinha.criaMenuFerramentas(mnFerramenta);
    menuBar.add(mnFerramenta);

    JMenu menuAjuda = new JMenu(GERAL.AJUDA);
    menuSilvinha.criaMenuAjuda(menuAjuda);
    menuBar.add(menuAjuda);

    return menuBar;
}

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

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

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

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

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

    menu.add(new JSeparator());

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

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

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

From source file:at.becast.youploader.gui.FrmMain.java

public void initMenuBar() {
    JMenuBar mnuBar = new JMenuBar();
    JMenu mnuFile = new JMenu();
    JMenuItem mnuQuit = new JMenuItem();
    mnuAcc = new JMenu();

    mnuFile.setText(LANG.getString("frmMain.menu.File"));

    mnuQuit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK));
    mnuQuit.setText(LANG.getString("frmMain.menu.Quit"));
    mnuQuit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            mnuQuitActionPerformed();//  w  ww  . ja va  2  s  . c o  m
        }
    });
    mnuFile.add(mnuQuit);

    mnuBar.add(mnuFile);

    mnuAcc.setText(LANG.getString("frmMain.menu.Account"));
    mnuBar.add(mnuAcc);

    JSeparator separator = new JSeparator();
    JMenuItem mntmAddAccount = new JMenuItem(LANG.getString("frmMain.menu.AddAccount"));
    mntmAddAccount.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            mntmAddAccountActionPerformed();
        }
    });
    mnuAcc.add(mntmAddAccount);
    mnuAcc.add(separator);

    JMenu mnLanguage = new JMenu("Language");
    mnLanguage.setVisible(false);
    mnLanguage.setEnabled(false);
    mnuBar.add(mnLanguage);

    JMenu menu = new JMenu("?");
    mnuBar.add(menu);

    JMenuItem mntmDonate = new JMenuItem(LANG.getString("frmMain.menu.Donate"));
    menu.add(mntmDonate);
    mntmDonate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            donateButton();
        }
    });

    JMenuItem mntmAbout = new JMenuItem(LANG.getString("frmMain.menu.About"));
    mntmAbout.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            FrmAbout about = new FrmAbout();
            about.setVisible(true);
        }
    });
    menu.add(mntmAbout);

    JMenuItem mntmShowLogfile = new JMenuItem(LANG.getString("frmMain.menu.ShowLogfile"));
    mntmShowLogfile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            DesktopUtil.openDir(new File(System.getProperty("user.home") + "/YouPloader"));
        }
    });
    menu.add(mntmShowLogfile);

    JMenuItem mntmUploadLogfile = new JMenuItem(LANG.getString("frmMain.menu.UploadLatestLogfile"));
    mntmUploadLogfile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            DesktopUtil.openDir(new File(System.getProperty("user.home") + "/YouPloader"));
        }
    });
    menu.add(mntmUploadLogfile);

    chckbxmntmCheckForUpdates = new JCheckBoxMenuItem(LANG.getString("frmMain.menu.CheckforUpdates"));
    menu.add(chckbxmntmCheckForUpdates);
    if (Main.s.setting.get("notify_updates").equals("1")) {
        chckbxmntmCheckForUpdates.setSelected(true);
    }
    chckbxmntmCheckForUpdates.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            toggleUpdateNotifier();
        }
    });
    setJMenuBar(mnuBar);
}