List of usage examples for javax.swing JMenu setMnemonic
@BeanProperty(visualUpdate = true, description = "the keyboard character mnemonic") public void setMnemonic(int mnemonic)
From source file:ee.ioc.cs.vsle.editor.Editor.java
/** * Build menu./*from w ww . j a v a2 s . co 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:fll.scheduler.SchedulerUI.java
private JMenu createScheduleMenu() { final JMenu menu = new JMenu("Schedule"); menu.setMnemonic('s'); menu.add(mOpenScheduleAction);/*from w w w . j a va 2 s .c om*/ menu.add(mReloadFileAction); menu.add(mRunOptimizerAction); menu.add(mWriteSchedulesAction); menu.add(mDisplayGeneralScheduleAction); return menu; }
From source file:fll.scheduler.SchedulerUI.java
private JMenu createDescriptionMenu() { final JMenu menu = new JMenu("Description"); menu.setMnemonic('d'); menu.add(mNewScheduleDescriptionAction); menu.add(mOpenScheduleDescriptionAction); menu.add(mSaveScheduleDescriptionAction); menu.add(mRunSchedulerAction);//from w w w .j a v a 2 s. com return menu; }
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);//from ww w . j ava2s .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 JMenu initCreateScriptsMenu() { JMenu mnCreateScript = new JMenu("Create script"); mnCreateScript.setMnemonic('C'); for (ODLAction action : new ScriptWizardActions(getApi(), this, scriptManager.getAvailableFieldsQuery()) .createComponentActions(new WizardActionsCallback() { @Override//ww w . j a v a 2 s .co m public void onNewScript(Script script) { scriptManager.launchScriptEditor(script, null, null); } })) { mnCreateScript.add(action); } return mnCreateScript; }
From source file:com.opendoorlogistics.studio.AppFrame.java
private JMenu initHelpMenu() { JMenu mnHelp = new JMenu("Help"); mnHelp.setMnemonic('H'); mnHelp.add(initGotoWebsiteAction()); mnHelp.add(new AbstractAction("About ODL Studio") { @Override//from w ww. j a va 2 s. co m public void actionPerformed(ActionEvent e) { final AboutBoxDialog dlg = new AboutBoxDialog(AppFrame.this, false); dlg.setLocationRelativeTo(AppFrame.this); dlg.setVisible(true); } }); mnHelp.add(new AbstractAction("List of data adapter functions") { @Override public void actionPerformed(ActionEvent e) { addInternalFrame(FunctionsListPanel.createFrame(), FramePlacement.AUTOMATIC); } }); mnHelp.add(new AbstractAction("List of 3rd party data & libraries") { @Override public void actionPerformed(ActionEvent e) { final AboutBoxDialog dlg = new AboutBoxDialog(AppFrame.this, true); dlg.setTitle("3rd party data & libs used in ODL Studio"); dlg.setLocationRelativeTo(AppFrame.this); dlg.setVisible(true); } }); return mnHelp; }
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(//from ww w. j ava 2 s . c o m 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); 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:com.adobe.aem.demo.gui.AemDemo.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private void initialize() { // Initialize properties setDefaultProperties(AemDemoUtils//from w w w . j av a 2 s. com .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:net.sf.jabref.gui.JabRefFrame.java
public static JMenu subMenu(String name) { int i = name.indexOf('&'); JMenu res; if (i >= 0) { res = new JMenu(name.substring(0, i) + name.substring(i + 1)); char mnemonic = Character.toUpperCase(name.charAt(i + 1)); res.setMnemonic((int) mnemonic); } else {//from w ww. j ava2 s. co m res = new JMenu(name); } return res; }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.analise_geral.PanelAnaliseGeral.java
/** * Cria o menu editar do Frame Principal * /*ww w . java 2 s . co m*/ * @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; }