List of usage examples for javax.swing JCheckBoxMenuItem JCheckBoxMenuItem
public JCheckBoxMenuItem(Action a)
From source file:net.sourceforge.entrainer.gui.EntrainerFX.java
private JMenuItem getSplashOnStartupItem() { splashOnStartup = new JCheckBoxMenuItem("Splash on Startup"); splashOnStartup.setToolTipText("Enables/Disables splash screen on startup"); splashOnStartup.addActionListener(e -> enableSplashOnStartup(splashOnStartup.isSelected())); return splashOnStartup; }
From source file:com.isencia.passerelle.hmi.HMIBase.java
/** * Constructs a default menu./*from w ww . j a v a 2s. c om*/ * <ul> * <li>If the menuItems set is null, all default items are created. * <li>If the set is not null, only the menu items whose names are in there * are shown * </ul> * For an overview of the names, check HMIMessages.MENU_... * * @param menuItemsToShow * @param menuItemsToHide * @return */ public JMenuBar createDefaultMenu(final Set<String> menuItemsToShow, final Set<String> menuItemsToHide) { final JMenuBar menuBar = new JMenuBar(); final JMenu fileMenu = new JMenu(HMIMessages.getString(HMIMessages.MENU_FILE)); fileMenu.setMnemonic(HMIMessages.getString(HMIMessages.MENU_FILE + HMIMessages.KEY).charAt(0)); if (showThing(HMIMessages.MENU_TEMPLATES, menuItemsToShow, menuItemsToHide)) { final JMenu templatesSubMenu = new JMenu(HMIMessages.getString(HMIMessages.MENU_TEMPLATES)); final Iterator itr = hmiModelsDef.getModels().keySet().iterator(); final List<String> orderedList = new ArrayList<String>(); while (itr.hasNext()) { final String modelKey = (String) itr.next(); final String labelKey = modelKey; // HMIMessages.getString(modelKey); orderedList.add(labelKey); } Collections.sort(orderedList); for (int i = 0; i < orderedList.size(); i++) { try { // JMenuItem templateMenuItem = new // JMenuItem(HMIMessages.getString(HMIMessages.MENU_TEMPLATES) // + " " + HMIMessages.getString(modelKey)); final JMenuItem templateMenuItem = new JMenuItem(HMIMessages.getString(orderedList.get(i))); templateMenuItem.addActionListener(new TemplateModelOpener(orderedList.get(i))); templatesSubMenu.add(templateMenuItem); } catch (final Exception e1) { e1.printStackTrace(); logger.error("", e1); } } fileMenu.add(templatesSubMenu); StateMachine.getInstance().registerActionForState(StateMachine.READY, HMIMessages.MENU_TEMPLATES, templatesSubMenu); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_TEMPLATES, templatesSubMenu); } if (showModelGraph) { if (showThing(HMIMessages.MENU_NEW, menuItemsToShow, menuItemsToHide)) { if (modelCreatorAction == null) { modelCreatorAction = new ModelCreator(this); } fileMenu.add(modelCreatorAction); // final JMenuItem fileNewMenuItem = new JMenuItem(HMIMessages // .getString(HMIMessages.MENU_NEW), HMIMessages.getString( // HMIMessages.MENU_NEW + HMIMessages.KEY).charAt(0)); // fileNewMenuItem.setAccelerator(KeyStroke.getKeyStroke( // KeyEvent.VK_N, InputEvent.CTRL_MASK)); // fileNewMenuItem.addActionListener(new ModelCreator()); // fileMenu.add(fileNewMenuItem); // StateMachine.getInstance().registerActionForState( // StateMachine.READY, HMIMessages.MENU_NEW, fileNewMenuItem); // StateMachine.getInstance().registerActionForState( // StateMachine.MODEL_OPEN, HMIMessages.MENU_NEW, // fileNewMenuItem); } } if (showThing(HMIMessages.MENU_OPEN, menuItemsToShow, menuItemsToHide)) { final JMenuItem fileOpenMenuItem = new JMenuItem(HMIMessages.getString(HMIMessages.MENU_OPEN), HMIMessages.getString(HMIMessages.MENU_OPEN + HMIMessages.KEY).charAt(0)); fileOpenMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); fileOpenMenuItem.addActionListener(new ModelOpener()); fileMenu.add(fileOpenMenuItem); StateMachine.getInstance().registerActionForState(StateMachine.READY, HMIMessages.MENU_OPEN, fileOpenMenuItem); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_OPEN, fileOpenMenuItem); } if (showThing(HMIMessages.MENU_CLOSE, menuItemsToShow, menuItemsToHide)) { final JMenuItem fileCloseMenuItem = new JMenuItem(HMIMessages.getString(HMIMessages.MENU_CLOSE), HMIMessages.getString(HMIMessages.MENU_CLOSE + HMIMessages.KEY).charAt(0)); fileCloseMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK)); fileCloseMenuItem.addActionListener(new ModelCloser()); fileMenu.add(fileCloseMenuItem); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_CLOSE, fileCloseMenuItem); } if (showThing(HMIMessages.MENU_SAVE, menuItemsToShow, menuItemsToHide)) { fileMenu.add(new JSeparator()); if (saveAction == null) { saveAction = new SaveAction(this); } fileMenu.add(saveAction); // StateMachine.getInstance().registerActionForState( // StateMachine.MODEL_OPEN, HMIMessages.MENU_SAVE, save); } if (showThing(HMIMessages.MENU_SAVEAS, menuItemsToShow, menuItemsToHide)) { if (saveAsAction == null) { saveAsAction = new SaveAsAction(this); } fileMenu.add(saveAsAction); // StateMachine.getInstance().registerActionForState( // StateMachine.MODEL_OPEN, HMIMessages.MENU_SAVEAS, save); } if (showThing(HMIMessages.MENU_EXIT, menuItemsToShow, menuItemsToHide)) { final JMenuItem exitMenuItem = new JMenuItem(HMIMessages.getString(HMIMessages.MENU_EXIT), HMIMessages.getString(HMIMessages.MENU_EXIT + HMIMessages.KEY).charAt(0)); exitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { if (logger.isTraceEnabled()) { logger.trace("Exit action - entry"); //$NON-NLS-1$ } logger.info(HMIMessages.getString(HMIMessages.INFO_EXIT)); // DBA to be validating... // Application which use HMIBase needs to call exit // treatment before exiting exitApplication(); if (logger.isTraceEnabled()) { logger.trace("Exit action - exit"); //$NON-NLS-1$ } System.exit(0); } }); fileMenu.add(new JSeparator()); fileMenu.add(exitMenuItem); StateMachine.getInstance().registerActionForState(StateMachine.READY, HMIMessages.MENU_EXIT, exitMenuItem); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_EXIT, exitMenuItem); } final JMenu runMenu = new JMenu(HMIMessages.getString(HMIMessages.MENU_RUN)); runMenu.setMnemonic(HMIMessages.getString(HMIMessages.MENU_RUN + HMIMessages.KEY).charAt(0)); if (showThing(HMIMessages.MENU_EXECUTE, menuItemsToShow, menuItemsToHide)) { if (modelExecutor == null) { modelExecutor = new ModelExecutor(this); } final JMenuItem runExecuteMenuItem = new JMenuItem(modelExecutor); runMenu.add(runExecuteMenuItem); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_EXECUTE, modelExecutor); } if (showThing(HMIMessages.MENU_STOP, menuItemsToShow, menuItemsToHide)) { if (modelStopper == null) { modelStopper = new ModelStopper(this); } final JMenuItem stopExecuteMenuItem = new JMenuItem(modelStopper); runMenu.add(stopExecuteMenuItem); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_EXECUTING, HMIMessages.MENU_STOP, modelStopper); } if (showThing(HMIMessages.MENU_INTERACTIVE_ERRORHANDLING, menuItemsToShow, menuItemsToHide)) { final JMenuItem interactiveErrorCtrlMenuItem = new JCheckBoxMenuItem( HMIMessages.getString(HMIMessages.MENU_INTERACTIVE_ERRORHANDLING)); interactiveErrorCtrlMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { interactiveErrorControl = ((JCheckBoxMenuItem) e.getSource()).getState(); } }); runMenu.add(new JSeparator()); runMenu.add(interactiveErrorCtrlMenuItem); } final JMenu graphMenu = new JMenu(HMIMessages.getString(HMIMessages.MENU_GRAPH)); graphMenu.setMnemonic(HMIMessages.getString(HMIMessages.MENU_GRAPH + HMIMessages.KEY).charAt(0)); // if (showThing(HMIMessages.MENU_SHOW, menuItemsToShow, // menuItemsToHide)) { // JMenuItem graphViewMenuItem = new // JCheckBoxMenuItem(HMIMessages.getString(HMIMessages.MENU_SHOW)); // graphMenu.add(graphViewMenuItem); // // graphViewMenuItem.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // if (logger.isTraceEnabled()) { // logger.trace("Graph Show action - entry"); //$NON-NLS-1$ // } // boolean showGraph = ((JCheckBoxMenuItem) e.getSource()).getState(); // if(showGraph) { // applyFieldValuesToParameters(); // clearModelForms(); // showModelGraph(HMIBase.this.currentModel.getName()); // } else { // clearModelGraphs(); // showModelForm(HMIBase.this.currentModel.getName()); // } // if (logger.isTraceEnabled()) { // logger.trace("Graph Show action - exit"); //$NON-NLS-1$ // } // } // // // }); // } if (showThing(HMIMessages.MENU_ANIMATE, menuItemsToShow, menuItemsToHide)) { final JMenuItem animateGraphViewMenuItem = new JCheckBoxMenuItem( HMIMessages.getString(HMIMessages.MENU_ANIMATE)); animateGraphViewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { animateModelExecution = ((JCheckBoxMenuItem) e.getSource()).getState(); } }); graphMenu.add(new JSeparator()); graphMenu.add(animateGraphViewMenuItem); } if (fileMenu.getMenuComponentCount() > 0) { menuBar.add(fileMenu); } if (runMenu.getMenuComponentCount() > 0) { menuBar.add(runMenu); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_RUN, runMenu); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_EXECUTING, HMIMessages.MENU_RUN, runMenu); } if (graphMenu.getMenuComponentCount() > 0) { menuBar.add(graphMenu); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, HMIMessages.MENU_GRAPH, graphMenu); StateMachine.getInstance().registerActionForState(StateMachine.MODEL_EXECUTING, HMIMessages.MENU_GRAPH, graphMenu); } final JMenu monitoringMenu = new JMenu(HMIMessages.getString(HMIMessages.MENU_MONITORING)); monitoringMenu.setMnemonic(HMIMessages.getString(HMIMessages.MENU_MONITORING + HMIMessages.KEY).charAt(0)); if (showThing(HMIMessages.MENU_TRACING, menuItemsToShow, menuItemsToHide)) { final JMenuItem traceMenuItem = new JMenuItem(HMIMessages.getString(HMIMessages.MENU_TRACING), HMIMessages.getString(HMIMessages.MENU_TRACING + HMIMessages.KEY).charAt(0)); traceMenuItem.addActionListener(new TraceDialogOpener()); monitoringMenu.add(traceMenuItem); } if (monitoringMenu.getMenuComponentCount() > 0) { menuBar.add(monitoringMenu); } StateMachine.getInstance().compile(); StateMachine.getInstance().transitionTo(StateMachine.READY); return menuBar; }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
private JMenuBar initMenuBar() { JMenuBar menubar = new JMenuBar(); {//from www .j a v a 2 s .c o m JMenu menu = new JMenu("Synchronisation"); { JMenuItem m = new JMenuItem("Kurse auswhlen"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { chooseCourses(); } }); menu.add(m); } { JMenuItem m = new JMenuItem("Automatische Synchronisation"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showAutoSyncSettings(); } }); menu.add(m); } { JMenuItem m = new JMenuItem("Neue Dateien zeigen"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showNewFiles(); } }); menu.add(m); } menubar.add(menu); } { JMenu menu = new JMenu("Einstellungen"); { JMenuItem m = new JMenuItem("Speicherpfad ndern"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changeBaseDir(); } }); menu.add(m); } { JMenuItem m = new JMenuItem("Speicherpfad ffnen"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openBaseDir(); } }); menu.add(m); } { JMenuItem m = new JMenuItem("Maximale Dateigre ndern"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changeMaxFileSize(); } }); menu.add(m); } { final JCheckBoxMenuItem menuitem = new JCheckBoxMenuItem( "Benachrichtigungen im Systemtray anzeigen"); menuitem.setSelected(iliasProperties.isShowNotifications()); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { iliasProperties.setShowNotifications(!iliasProperties.isShowNotifications()); saveProperties(iliasProperties); menuitem.setSelected(iliasProperties.isShowNotifications()); } }); menu.add(menuitem); } { menu.add(new JSeparator()); } { JMenuItem m = new JMenuItem("Design ndern"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changeLookAndFeel(); } }); menu.add(m); } { menu.add(new JSeparator()); } { JMenuItem m = new JMenuItem("Server einstellen"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { chooseServer(); } }); menu.add(m); } menubar.add(menu); } { JMenu menu = new JMenu("Hilfe"); { JMenuItem m = new JMenuItem("Fehler melden, Feedback geben"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFeedbackPage(); } }); menu.add(m); } { JMenuItem m = new JMenuItem("Webseite"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openWebsite(); } }); menu.add(m); } { JMenuItem m = new JMenuItem("Android App"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openAndroidWebsite(); } }); menu.add(m); } { JMenuItem m = new JMenuItem("Info"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showInfo(); } }); menu.add(m); } menubar.add(menu); } return menubar; }
From source file:org.gumtree.vis.awt.time.TimePlotPanel.java
@Override protected JPopupMenu createPopupMenu(boolean properties, boolean copy, boolean save, boolean print, boolean zoom) { JPopupMenu menu = super.createPopupMenu(properties, copy, save, print, zoom); menu.addSeparator();/*www. j a va 2 s . c o m*/ legendMenu = new JMenu("Legend Position"); menu.add(legendMenu); legendNone = new JRadioButtonMenuItem("None"); legendNone.setActionCommand(LEGEND_NONE_COMMAND); legendNone.addActionListener(this); legendMenu.add(legendNone); legendBottom = new JRadioButtonMenuItem("Bottom"); legendBottom.setActionCommand(LEGEND_BOTTOM_COMMAND); legendBottom.addActionListener(this); legendMenu.add(legendBottom); legendRight = new JRadioButtonMenuItem("Right"); legendRight.setActionCommand(LEGEND_RIGHT_COMMAND); legendRight.addActionListener(this); legendMenu.add(legendRight); menu.addSeparator(); curveManagementMenu = new JMenu("Focus on Curve"); menu.add(curveManagementMenu); menu.addSeparator(); showMultiAxesMenuItem = new JCheckBoxMenuItem("Show Multiple Vertical Axes"); showMultiAxesMenuItem.setActionCommand(SHOW_MULTI_AXES_COMMAND); showMultiAxesMenuItem.addActionListener(this); menu.add(showMultiAxesMenuItem); menu.addSeparator(); curveResetMenu = new JMenu("Reset Curve"); menu.add(curveResetMenu); menu.addSeparator(); pauseMenuItem = new JCheckBoxMenuItem("Paused"); pauseMenuItem.setActionCommand(TOGGLE_PAUSED_COMMAND); pauseMenuItem.addActionListener(this); menu.add(pauseMenuItem); return menu; }
From source file:gui.DownloadManagerGUI.java
private JMenuBar initMenuBar() { JMenuBar menuBar = new JMenuBar(); ///////////////////////////////////////////////////////////////////////// JMenu fileMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.fileMenu.name")); exportDataItem = new JMenuItem("Export Data..."); importDataItem = new JMenuItem("Import Data..."); exitItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.exitItem.name")); exitItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.exitItem.iconPath")))); // NOI18N exportDataItem.setEnabled(false);//from ww w . j a va2s . c o m importDataItem.setEnabled(false); // fileMenu.add(exportDataItem); // fileMenu.add(importDataItem); fileMenu.addSeparator(); fileMenu.add(exitItem); ///////////////////////////////////////////////////////////////////////// JMenu windowMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.windowMenu.name")); JMenu showMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.showMenu.name")); prefsItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.prefsItem.name")); prefsItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.prefsItem.iconPath")))); JCheckBoxMenuItem showFormItem = new JCheckBoxMenuItem( messagesBundle.getString("downloadManagerGUI.showFormItem.name")); showFormItem.setSelected(true); showMenu.add(showFormItem); windowMenu.add(showMenu); windowMenu.add(prefsItem); exportDataItem.addActionListener(this); importDataItem.addActionListener(this); exitItem.addActionListener(this); prefsItem.addActionListener(this); ///////////////////////////////////////////////////////////////////////// JMenu downloadsMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.downloadsMenu.name")); newDownloadItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.newDownloadItem.name")); newDownloadItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.newDownloadItem.iconPath")))); openItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.openItem.name")); openFolderItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.openFolderItem.name")); resumeItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.resumeItem.name")); resumeItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.resumeItem.iconPath")))); pauseItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.pauseItem.name")); pauseItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.pauseItem.iconPath")))); pauseAllItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.pauseAllItem.name")); pauseAllItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.pauseAllItem.iconPath")))); clearItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.clearItem.name")); clearItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.clearItem.iconPath")))); clearAllCompletedItem = new JMenuItem( messagesBundle.getString("downloadManagerGUI.clearAllCompletedItem.name")); clearAllCompletedItem.setIcon(new javax.swing.ImageIcon(getClass() .getResource(messagesBundle.getString("downloadManagerGUI.clearAllCompletedItem.iconPath")))); reJoinItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.reJoinItem.name")); reJoinItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.reJoinItem.iconPath")))); reDownloadItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.reDownloadItem.name")); reDownloadItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.reDownloadItem.iconPath")))); moveToQueueItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.moveToQueueItem.name")); removeFromQueueItem = new JMenuItem( messagesBundle.getString("downloadManagerGUI.removeFromQueueItem.name")); propertiesItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.propertiesItem.name")); propertiesItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.propertiesItem.iconPath")))); downloadsMenu.add(newDownloadItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(openItem); downloadsMenu.add(openFolderItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(resumeItem); downloadsMenu.add(pauseItem); downloadsMenu.add(pauseAllItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(clearItem); downloadsMenu.add(clearAllCompletedItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(reJoinItem); downloadsMenu.add(reDownloadItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(moveToQueueItem); downloadsMenu.add(removeFromQueueItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(propertiesItem); newDownloadItem.addActionListener(this); openItem.addActionListener(this); openFolderItem.addActionListener(this); resumeItem.addActionListener(this); pauseItem.addActionListener(this); pauseAllItem.addActionListener(this); clearItem.addActionListener(this); clearAllCompletedItem.addActionListener(this); reDownloadItem.addActionListener(this); moveToQueueItem.addActionListener(this); removeFromQueueItem.addActionListener(this); propertiesItem.addActionListener(this); setStateOfMenuItems(); ///////////////////////////////////////////////////////////////////////// JMenu helpMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.helpMenu.name")); aboutItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.aboutItem.name")); aboutItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.aboutItem.iconPath")))); helpMenu.add(aboutItem); aboutItem.addActionListener(this); menuBar.add(fileMenu); menuBar.add(windowMenu); menuBar.add(downloadsMenu); menuBar.add(helpMenu); showFormItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ev.getSource(); if (menuItem.isSelected()) { mainSplitPane.setDividerLocation((int) categoryPanel.getMinimumSize().getWidth()); } categoryPanel.setVisible(menuItem.isSelected()); } }); fileMenu.setMnemonic(KeyEvent.VK_F); exitItem.setMnemonic(KeyEvent.VK_X); prefsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK)); exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); importDataItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK)); return menuBar; }
From source file:de.huxhorn.lilith.swing.ViewActions.java
private void updateShowHideMenu() { columnsMenu.removeAll();/*from w w w . java2 s. co m*/ if (viewContainer != null) { EventWrapperViewPanel<?> viewPanel = viewContainer.getSelectedView(); if (viewPanel != null) { EventWrapperViewTable<?> table = viewPanel.getTable(); if (table != null) { PersistentTableColumnModel tableColumnModel = table.getTableColumnModel(); List<PersistentTableColumnModel.TableColumnLayoutInfo> cli = tableColumnModel .getColumnLayoutInfos(); for (PersistentTableColumnModel.TableColumnLayoutInfo current : cli) { boolean visible = current.isVisible(); JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem( new ShowHideAction(tableColumnModel, current.getColumnName(), visible)); cbmi.setSelected(visible); columnsMenu.add(cbmi); } } } } }
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();/*from w w w . j ava 2 s. c om*/ } }); 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); }
From source file:ffx.ui.ModelingPanel.java
private void initialize() { // Command Description descriptTextArea = new JTextArea(); descriptTextArea.setEditable(false); descriptTextArea.setLineWrap(true);/*from w w w . j a va 2s. c o m*/ descriptTextArea.setWrapStyleWord(true); descriptTextArea.setDoubleBuffered(true); Insets insets = descriptTextArea.getInsets(); insets.set(5, 5, 5, 5); descriptTextArea.setMargin(insets); descriptScrollPane = new JScrollPane(descriptTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); descriptScrollPane.setBorder(etchedBorder); // Command Input commandTextArea = new JTextArea(); commandTextArea.setEditable(false); commandTextArea.setLineWrap(true); commandTextArea.setWrapStyleWord(true); commandTextArea.setDoubleBuffered(true); commandTextArea.setMargin(insets); // Command Options optionsTabbedPane = new JTabbedPane(); statusLabel = new JLabel(); statusLabel.setBorder(etchedBorder); statusLabel.setToolTipText(" Modeling command that will be executed"); commandPanel = new JPanel(flowLayout); commandPanel.add(optionsTabbedPane); splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, commandPanel, descriptScrollPane); splitPane.setContinuousLayout(true); splitPane.setResizeWeight(1.0d); splitPane.setOneTouchExpandable(true); setLayout(new BorderLayout()); add(splitPane, BorderLayout.CENTER); add(statusLabel, BorderLayout.SOUTH); // Initialize the Amino/Nucleic Acid ComboBox. acidComboBox.setEditable(false); acidComboBox.setMaximumSize(sizer.getPreferredSize()); acidComboBox.setPreferredSize(sizer.getPreferredSize()); acidComboBox.setMinimumSize(sizer.getPreferredSize()); acidComboBox.setFont(Font.decode("Monospaced")); acidTextField.setMaximumSize(sizer.getPreferredSize()); acidTextField.setMinimumSize(sizer.getPreferredSize()); acidTextField.setPreferredSize(sizer.getPreferredSize()); acidTextArea.setEditable(false); acidTextArea.setWrapStyleWord(true); acidTextArea.setLineWrap(true); acidTextArea.setFont(Font.decode("Monospaced")); acidScrollPane = new JScrollPane(acidTextArea); Dimension d = new Dimension(300, 400); acidScrollPane.setPreferredSize(d); acidScrollPane.setMaximumSize(d); acidScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); // Load the FFX commands.xml file that defines FFX commands. try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver(new DTDResolver()); URL comURL = getClass().getClassLoader().getResource("ffx/ui/commands/commands.xml"); Document doc = db.parse(comURL.openStream()); NodeList nodelist = doc.getChildNodes(); Node commandroot = null; for (int i = 0; i < nodelist.getLength(); i++) { commandroot = nodelist.item(i); if (commandroot.getNodeName().equals("FFXCommands") && commandroot instanceof Element) { break; } } if (commandroot == null || !(commandroot instanceof Element)) { commandList = null; } commandList = ((Element) commandroot).getElementsByTagName("Command"); } catch (ParserConfigurationException | SAXException | IOException e) { System.err.println(e); } finally { if (commandList == null) { System.out.println("Force Field X commands.xml could not be parsed."); logger.severe("Force Field X will exit."); System.exit(-1); } } // Create a ComboBox with commands specific to each type of coordinate // file. xyzCommands = new JComboBox<>(); intCommands = new JComboBox<>(); arcCommands = new JComboBox<>(); pdbCommands = new JComboBox<>(); anyCommands = new JComboBox<>(); Element command; String name; int numcommands = commandList.getLength(); for (int i = 0; i < numcommands; i++) { command = (Element) commandList.item(i); name = command.getAttribute("name"); String temp = command.getAttribute("fileType"); if (temp.contains("ANY")) { temp = "XYZ INT ARC PDB"; anyCommands.addItem(name); } String[] types = temp.split(" +"); for (String type : types) { if (type.contains("XYZ")) { xyzCommands.addItem(name); } if (type.contains("INT")) { intCommands.addItem(name); } if (type.contains("ARC")) { arcCommands.addItem(name); } if (type.contains("PDB")) { pdbCommands.addItem(name); } } } initCommandComboBox(xyzCommands); initCommandComboBox(intCommands); initCommandComboBox(arcCommands); initCommandComboBox(pdbCommands); initCommandComboBox(anyCommands); currentCommandBox = anyCommands; activeCommand = (String) anyCommands.getSelectedItem(); // Load the default Command. loadCommand(); // Load the default Log File Settings. logSettings.setActionCommand("LogSettings"); loadLogSettings(); // Create the Toolbar. toolBar = new JToolBar("Modeling Commands", JToolBar.HORIZONTAL); toolBar.setLayout(new FlowLayout(FlowLayout.LEFT)); jbLaunch = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/cog_go.png"))); jbLaunch.setActionCommand("Launch"); jbLaunch.setToolTipText("Launch the Force Field X Command"); jbLaunch.addActionListener(this); insets.set(2, 2, 2, 2); jbLaunch.setMargin(insets); toolBar.add(jbLaunch); jbStop = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/stop.png"))); jbStop.setActionCommand("End"); jbStop.setToolTipText("Terminate the Current Force Field X Command"); jbStop.addActionListener(this); jbStop.setMargin(insets); jbStop.setEnabled(false); toolBar.add(jbStop); toolBar.addSeparator(); toolBar.add(anyCommands); currentCommandBox = anyCommands; toolBar.addSeparator(); /* toolBar.add(logSettings); JButton jbdelete = new JButton(new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/page_delete.png"))); jbdelete.setActionCommand("Delete"); jbdelete.setToolTipText("Delete Log Files"); jbdelete.addActionListener(this); jbdelete.setMargin(insets); toolBar.add(jbdelete); toolBar.addSeparator(); */ ImageIcon icinfo = new ImageIcon(getClass().getClassLoader().getResource("ffx/ui/icons/information.png")); descriptCheckBox = new JCheckBoxMenuItem(icinfo); descriptCheckBox.addActionListener(this); descriptCheckBox.setActionCommand("Description"); descriptCheckBox.setToolTipText("Show/Hide Modeling Command Descriptions"); descriptCheckBox.setMargin(insets); toolBar.add(descriptCheckBox); toolBar.add(new JLabel("")); toolBar.setBorderPainted(false); toolBar.setFloatable(false); toolBar.setRollover(true); add(toolBar, BorderLayout.NORTH); // Load ModelingPanel preferences. Preferences prefs = Preferences.userNodeForPackage(ffx.ui.ModelingPanel.class); descriptCheckBox.setSelected(!prefs.getBoolean("JobPanel_description", true)); descriptCheckBox.doClick(); }
From source file:net.sourceforge.entrainer.gui.EntrainerFX.java
private JMenuItem getConnectSocketItem() { connect = new JCheckBoxMenuItem("Accept Connections"); connect.addActionListener(new ActionListener() { @Override//from w w w. j a v a2 s. c om public void actionPerformed(ActionEvent arg0) { if (connect.isSelected()) { bindSocket(); } else { unbindSocket(); } } }); connect.setToolTipText("Bind / unbind the socket on which Entrainer sends and receives state messages"); return connect; }
From source file:edu.ku.brc.ui.UIHelper.java
/** * Creates a JCheckBoxMenuItem.//from ww w . jav a2 s .co m * @param menu parent menu * @param label the label of the menu item * @param mnemonic the mnemonic * @param accessibleDescription the accessible Description * @param enabled enabled * @param action the aciton * @return menu item */ public static JCheckBoxMenuItem createCheckBoxMenuItem(final JMenu menu, final String label, final String mnemonic, final String accessibleDescription, final boolean enabled, final AbstractAction action) { JCheckBoxMenuItem mi = new JCheckBoxMenuItem(getResourceString(label)); if (menu != null) { menu.add(mi); } setLocalizedMnemonic(mi, mnemonic); if (isNotEmpty(accessibleDescription)) { mi.getAccessibleContext().setAccessibleDescription(accessibleDescription); } if (action != null) { mi.addActionListener(action); action.addPropertyChangeListener(new MenuItemPropertyChangeListener(mi)); action.setEnabled(enabled); } return mi; }