List of usage examples for javax.swing JCheckBoxMenuItem setSelected
public void setSelected(boolean b)
From source file:com.mirth.connect.client.ui.components.MirthTreeTable.java
private JPopupMenu getColumnMenu() { SortableTreeTableModel model = (SortableTreeTableModel) getTreeTableModel(); JPopupMenu columnMenu = new JPopupMenu(); for (int i = 0; i < model.getColumnCount(); i++) { final String columnName = model.getColumnName(i); // Get the column object by name. Using an index may not return the column object if the column is hidden TableColumnExt column = getColumnExt(columnName); // Create the menu item final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(columnName); // Show or hide the checkbox menuItem.setSelected(column.isVisible()); menuItem.addActionListener(new ActionListener() { @Override//from w w w. j ava 2 s . co m public void actionPerformed(ActionEvent arg0) { TableColumnExt column = getColumnExt(menuItem.getText()); // Determine whether to show or hide the selected column boolean enable = !column.isVisible(); // Do not hide a column if it is the last remaining visible column if (enable || getColumnCount() > 1) { column.setVisible(enable); Set<String> customHiddenColumns = customHiddenColumnMap.get(channelId); if (customHiddenColumns != null) { if (enable) { customHiddenColumns.remove(columnName); } else { customHiddenColumns.add(columnName); } } } saveColumnOrder(); } }); columnMenu.add(menuItem); } columnMenu.addSeparator(); JMenuItem menuItem = new JMenuItem("Collapse All"); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { collapseAll(); } }); columnMenu.add(menuItem); menuItem = new JMenuItem("Expand All"); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { expandAll(); } }); columnMenu.add(menuItem); columnMenu.addSeparator(); menuItem = new JMenuItem("Restore Default"); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (metaDataColumns != null) { defaultVisibleColumns.addAll(metaDataColumns); } restoreDefaultColumnPreferences(); } }); columnMenu.add(menuItem); return columnMenu; }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java
private void removeAllMetricsOfAGroup(JMenu menu) { JCheckBoxMenuItem item = null; String name = null;// w w w. j a va 2 s.co m for (int i = 0; i < menu.getMenuComponentCount(); i++) { if (menu.getMenuComponent(i) instanceof JCheckBoxMenuItem) { item = (JCheckBoxMenuItem) menu.getMenuComponent(i); name = item.getActionCommand(); if (item.isSelected()) { item.setSelected(false); deletePlotInWindow(name); } } } }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java
private void displayAllMetricsOfAGroup(JMenu menu) { JCheckBoxMenuItem item = null; String name = null;/*from w w w.ja v a 2 s . c om*/ for (int i = 0; i < menu.getMenuComponentCount(); i++) { if (menu.getMenuComponent(i) instanceof JCheckBoxMenuItem) { item = (JCheckBoxMenuItem) menu.getMenuComponent(i); name = item.getActionCommand(); if (!item.isSelected()) { item.setSelected(true); createPlotInWindow(name); } } } }
From source file:org.jax.maanova.test.gui.VolcanoPlotPanel.java
@SuppressWarnings("serial") private JMenuBar createMenu() { JMenuBar menuBar = new JMenuBar(); // the file menu JMenu fileMenu = new JMenu("File"); fileMenu.add(this.saveGraphImageAction); menuBar.add(fileMenu);/*from w w w .java 2 s .com*/ // the tools menu JMenu toolsMenu = new JMenu("Tools"); JMenuItem configureGraphItem = new JMenuItem("Configure Graph..."); configureGraphItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.chartConfigurationDialog.setVisible(true); } }); toolsMenu.add(configureGraphItem); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Clear Selections") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.setSelectedIndices(new int[0]); } }); toolsMenu.addSeparator(); ButtonGroup dragButtonGroup = new ButtonGroup(); JCheckBoxMenuItem selectModeCheckBox = new JCheckBoxMenuItem("Drag Cursor to Select"); selectModeCheckBox.setSelected(true); this.dragToSelect = true; selectModeCheckBox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.dragToSelect = e.getStateChange() == ItemEvent.SELECTED; } }); dragButtonGroup.add(selectModeCheckBox); toolsMenu.add(selectModeCheckBox); JCheckBoxMenuItem zoomModeCheckBox = new JCheckBoxMenuItem("Drag Cursor to Zoom"); zoomModeCheckBox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.dragToZoom = e.getStateChange() == ItemEvent.SELECTED; } }); dragButtonGroup.add(zoomModeCheckBox); toolsMenu.add(zoomModeCheckBox); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Zoom Out") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.autoRangeChart(); } }); toolsMenu.addSeparator(); JCheckBoxMenuItem showTooltipCheckbox = new JCheckBoxMenuItem("Show Info Popup for Nearest Point"); showTooltipCheckbox.setSelected(true); this.showTooltip = true; showTooltipCheckbox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.showTooltip = e.getStateChange() == ItemEvent.SELECTED; VolcanoPlotPanel.this.clearProbePopup(); } }); toolsMenu.add(showTooltipCheckbox); toolsMenu.addSeparator(); toolsMenu.add(this.displayTestResultsAction); toolsMenu.addSeparator(); toolsMenu.add(this.saveSelectedPointsMenuItem); JMenu selectPointsFromLisMenu = new JMenu("Select Points From Gene List"); List<String> geneListNames = this.maanovaTestResult.getParentExperiment().getGeneListNames(); if (geneListNames.isEmpty()) { JMenuItem noListsMenuItem = new JMenuItem("No Gene Lists Available"); noListsMenuItem.setEnabled(false); selectPointsFromLisMenu.add(noListsMenuItem); } else { for (final String geneListName : geneListNames) { JMenuItem currGeneListMenuItem = new JMenuItem( RUtilities.fromRIdentifierToReadableName(geneListName)); currGeneListMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.selectedIndicesFromGeneList(geneListName); } }); selectPointsFromLisMenu.add(currGeneListMenuItem); } } toolsMenu.add(selectPointsFromLisMenu); menuBar.add(toolsMenu); // the help menu JMenu helpMenu = new JMenu("Help"); JMenuItem helpMenuItem = new JMenuItem("Help..."); Icon helpIcon = new ImageIcon(VolcanoPlotPanel.class.getResource("/images/action/help-16x16.png")); helpMenuItem.setIcon(helpIcon); helpMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { Maanova.getInstance().showHelp("volcano-plot", VolcanoPlotPanel.this); } }); helpMenu.add(helpMenuItem); menuBar.add(helpMenu); return menuBar; }
From source file:gui.DownloadManagerGUI.java
private JMenuBar initMenuBar() { JMenuBar menuBar = new JMenuBar(); ///////////////////////////////////////////////////////////////////////// JMenu fileMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.fileMenu.name")); exportDataItem = new JMenuItem("Export Data..."); importDataItem = new JMenuItem("Import Data..."); exitItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.exitItem.name")); exitItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.exitItem.iconPath")))); // NOI18N exportDataItem.setEnabled(false);// w ww . ja v a2 s .com 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:oct.analysis.application.OCTAnalysisUI.java
private void screenSelectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_screenSelectButtonActionPerformed toolMode = (toolMode == ToolMode.SCREEN_SELECT) ? ToolMode.NONE : ToolMode.SCREEN_SELECT; for (MenuElement elm : toolsMenu.getSubElements()) { if (elm instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) elm; menuItem.setSelected(false); }//from www . j av a 2s . com } }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
private JMenuBar initMenuBar() { JMenuBar menubar = new JMenuBar(); {/*from w w w. j av a 2s. co 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:ee.ioc.cs.vsle.editor.Editor.java
/** * Build menu./*from ww w . j a v a 2s . 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:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java
@Override public JPopupMenu getComponentPopupMenu() { JPopupMenu popupMenu = getFileChooser().getComponentPopupMenu(); if (popupMenu != null) { return popupMenu; }/* ww w . j a v a2 s. com*/ JMenu aViewMenu = getViewMenu(); if (contextMenu == null) { contextMenu = new JPopupMenu(); if (aViewMenu != null) { contextMenu.add(aViewMenu); if (listViewWindowsStyle) { contextMenu.addSeparator(); } } ActionMap actionMap = getActionMap(); Action refreshAction = actionMap.get(ACTION_REFRESH); Action aNewFolderAction = actionMap.get(ACTION_NEW_FOLDER); Action showHiddenFiles = actionMap.get(ACTION_VIEW_HIDDEN); if (refreshAction != null) { contextMenu.add(refreshAction); if (listViewWindowsStyle && (aNewFolderAction != null)) { contextMenu.addSeparator(); } } if (showHiddenFiles != null) { JCheckBoxMenuItem menuitem = new JCheckBoxMenuItem(showHiddenFiles); menuitem.setSelected((Boolean) showHiddenFiles.getValue(Action.SELECTED_KEY)); contextMenu.add(menuitem); } if (aNewFolderAction != null) { contextMenu.add(aNewFolderAction); } } if (aViewMenu != null) { aViewMenu.getPopupMenu().setInvoker(aViewMenu); } return contextMenu; }
From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java
/** * Build menu items for TA.// w ww .ja va2 s .c om */ private void buildTAMenuItems() { final int[] days = { 14, 28, 50, 100, 200 }; final MACD.Period[] macd_periods = { MACD.Period.newInstance(12, 26, 9) }; // day_keys, week_keys and month_keys should be having same length as // days. final String[] day_keys = { "ChartJDialog_14Days", "ChartJDialog_28Days", "ChartJDialog_50Days", "ChartJDialog_100Days", "ChartJDialog_200Days" }; final String[] week_keys = { "ChartJDialog_14Weeks", "ChartJDialog_28Weeks", "ChartJDialog_50Weeks", "ChartJDialog_100Weeks", "ChartJDialog_200Weeks" }; final String[] month_keys = { "ChartJDialog_14Months", "ChartJDialog_28Months", "ChartJDialog_50Months", "ChartJDialog_100Months", "ChartJDialog_200Months" }; assert (days.length == day_keys.length); assert (days.length == week_keys.length); assert (days.length == week_keys.length); // macd_day_keys, macd_week_keys and macd_month_keys should be having // same length as macd_periods. final String[] macd_day_keys = { "ChartJDialog_12_26_9Days" }; final String[] macd_week_keys = { "ChartJDialog_12_26_9Weeks" }; final String[] macd_month_keys = { "ChartJDialog_12_26_9Months" }; assert (macd_periods.length == macd_day_keys.length); assert (macd_periods.length == macd_week_keys.length); assert (macd_periods.length == macd_month_keys.length); String[] keys = null; String[] macd_keys = null; if (this.getCurrentInterval() == Interval.Daily) { keys = day_keys; macd_keys = macd_day_keys; } else if (this.getCurrentInterval() == Interval.Weekly) { keys = week_keys; macd_keys = macd_week_keys; } else if (this.getCurrentInterval() == Interval.Monthly) { keys = month_keys; macd_keys = macd_month_keys; } else { assert (false); } final TA[] tas = TA.values(); final String[] ta_keys = { "ChartJDialog_SMA", "ChartJDialog_EMA", "ChartJDialog_MACD", "ChartJDialog_RSI", "ChartJDialog_MFI", "ChartJDialog_CCI" }; final String[] ta_tip_keys = { "ChartJDialog_SimpleMovingAverage", "ChartJDialog_ExponentialMovingAverage", "ChartJDialog_MovingAverageConvergenceDivergence", "ChartJDialog_RelativeStrengthIndex", "ChartJDialog_MoneyFlowIndex", "ChartJDialog_CommodityChannelIndex" }; final String[] custom_message_keys = { "info_message_please_enter_number_of_days_for_SMA", "info_message_please_enter_number_of_days_for_EMA", "dummy", "info_message_please_enter_number_of_days_for_RSI", "info_message_please_enter_number_of_days_for_MFI", "info_message_please_enter_number_of_days_for_CCI" }; final Map<TA, Set<Object>> m = new EnumMap<TA, Set<Object>>(TA.class); final int taExSize = JStock.instance().getChartJDialogOptions().getTAExSize(); for (int i = 0; i < taExSize; i++) { final TAEx taEx = JStock.instance().getChartJDialogOptions().getTAEx(i); if (m.containsKey(taEx.getTA()) == false) { m.put(taEx.getTA(), new HashSet<Object>()); } m.get(taEx.getTA()).add(taEx.getParameter()); } for (int i = 0, length = tas.length; i < length; i++) { final TA ta = tas[i]; javax.swing.JMenu menu = new javax.swing.JMenu(); menu.setText(GUIBundle.getString(ta_keys[i])); // NOI18N menu.setToolTipText(GUIBundle.getString(ta_tip_keys[i])); // NOI18N if (ta == TA.MACD) { for (int j = 0, length2 = macd_periods.length; j < length2; j++) { final int _j = j; final javax.swing.JCheckBoxMenuItem item = new javax.swing.JCheckBoxMenuItem(); item.setText(GUIBundle.getString(macd_keys[j])); if (m.containsKey(ta)) { if (m.get(ta).contains(macd_periods[_j])) { item.setSelected(true); } } item.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { if (ta == TA.MACD) { updateMACD(macd_periods[_j], item.isSelected()); } } }); menu.add(item); } } else { for (int j = 0, length2 = days.length; j < length2; j++) { final int _j = j; final javax.swing.JCheckBoxMenuItem item = new javax.swing.JCheckBoxMenuItem(); item.setText(GUIBundle.getString(keys[j])); // NOI18N if (m.containsKey(ta)) { if (m.get(ta).contains(days[_j])) { item.setSelected(true); } } item.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { if (ta == TA.SMA) { updateSMA(days[_j], item.isSelected()); } else if (ta == TA.EMA) { updateEMA(days[_j], item.isSelected()); } else if (ta == TA.MFI) { updateMFI(days[_j], item.isSelected()); } else if (ta == TA.RSI) { updateRSI(days[_j], item.isSelected()); } else if (ta == TA.CCI) { updateCCI(days[_j], item.isSelected()); } } }); menu.add(item); } // for } // if (ta == TA.MACD) menu.add(new javax.swing.JSeparator()); javax.swing.JMenuItem item = new javax.swing.JMenuItem(); item.setText(GUIBundle.getString("ChartJDialog_Custom...")); // NOI18N final int _i = i; item.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { if (ta == TA.MACD) { showMACDCustomDialog(); } else { do { final String days_string = JOptionPane.showInputDialog(ChartJDialog.this, MessagesBundle.getString(custom_message_keys[_i])); if (days_string == null) { return; } try { final int days = Integer.parseInt(days_string); if (days <= 0) { JOptionPane.showMessageDialog(ChartJDialog.this, MessagesBundle.getString("info_message_number_of_days_required"), MessagesBundle.getString("info_title_number_of_days_required"), JOptionPane.WARNING_MESSAGE); continue; } ChartJDialog.this.updateTA(ta, days, true); return; } catch (java.lang.NumberFormatException exp) { log.error(null, exp); JOptionPane.showMessageDialog(ChartJDialog.this, MessagesBundle.getString("info_message_number_of_days_required"), MessagesBundle.getString("info_title_number_of_days_required"), JOptionPane.WARNING_MESSAGE); continue; } } while (true); } } }); menu.add(item); // TEMP DISABLE MACD // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if (ta != TA.MACD) { this.jMenu2.add(menu); } } // for this.jMenu2.add(new javax.swing.JSeparator()); javax.swing.JMenuItem item = new javax.swing.JMenuItem(); item.setText(GUIBundle.getString("ChartJDialog_ClearAll")); // NOI18N item.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { ChartJDialog.this.clearAll(); } }); this.jMenu2.add(item); }