Java Code Examples for javax.swing.JMenu#setEnabled()
The following examples show how to use
javax.swing.JMenu#setEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionMappings.java From netbeans with Apache License 2.0 | 6 votes |
@Messages("ActionMappings.jdkVar=Use JDK for Maven build") private static JMenu createJdkSubmenu(JTextComponent area) { JMenu menu = new JMenu(); menu.setText(ActionMappings_jdkVar()); boolean hasAny = false; for (JavaPlatform platform : JavaPlatformManager.getDefault().getInstalledPlatforms()) { hasAny = true; if (platform.getInstallFolders().size() > 0) { menu.add(new JdkAction(area, platform.getDisplayName(), platform.getInstallFolders().iterator().next())); } } if (!hasAny) { menu.setEnabled(false); } return menu; }
Example 2
Source File: MainMenu.java From tda with GNU Lesser General Public License v2.1 | 6 votes |
/** * create the menu for opening recently selected files. */ private void createRecentSessionsMenu() { String[] recentFiles = PrefManager.get().getRecentSessions(); recentSessionsMenu = new JMenu(ResourceManager.translate("file.recentsessions")); recentSessionsMenu.setMnemonic(KeyStroke.getKeyStroke(ResourceManager.translate("file.recentsessions.mnem")).getKeyCode()); if(recentFiles.length > 1) { for(int i = 1; i < recentFiles.length; i++) { if(!recentFiles[i].equals("")) { JMenuItem item = new JMenuItem(recentFiles[i]); ((JMenu) recentSessionsMenu).add(item); item.addActionListener(listener); } } } else { recentSessionsMenu.setEnabled(false); } }
Example 3
Source File: MainMenu.java From tda with GNU Lesser General Public License v2.1 | 6 votes |
/** * create the menu for opening recently selected files. */ private void createRecentFileMenu() { String[] recentFiles = PrefManager.get().getRecentFiles(); recentFilesMenu = new JMenu(ResourceManager.translate("file.recentfiles")); recentFilesMenu.setMnemonic(KeyStroke.getKeyStroke(ResourceManager.translate("file.recentfiles.mnem")).getKeyCode()); if(recentFiles.length > 1) { for(int i = 1; i < recentFiles.length; i++) { if(!recentFiles[i].equals("")) { JMenuItem item = new JMenuItem(recentFiles[i]); ((JMenu) recentFilesMenu).add(item); item.addActionListener(listener); } } } else { recentFilesMenu.setEnabled(false); } }
Example 4
Source File: MainFrame.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
private void enableMenu(final JMenu menu) { menu.setEnabled(true); for (final Component c : menu.getMenuComponents()) { if (c instanceof JMenu) { enableMenu((JMenu) c); } else if (c instanceof JMenuItem) { ((JMenuItem) c).setEnabled(true); } } }
Example 5
Source File: ViewMenu.java From triplea with GNU General Public License v3.0 | 5 votes |
private void addMapSkinsMenu() { final JMenu mapSubMenu = new JMenu("Map Skins"); mapSubMenu.setMnemonic(KeyEvent.VK_K); add(mapSubMenu); final ButtonGroup mapButtonGroup = new ButtonGroup(); final Map<String, String> skins = AbstractUiContext.getSkins(frame.getGame().getData()); mapSubMenu.setEnabled(skins.size() > 1); for (final String key : skins.keySet()) { final JMenuItem mapMenuItem = new JRadioButtonMenuItem(key); mapButtonGroup.add(mapMenuItem); mapSubMenu.add(mapMenuItem); if (skins.get(key).equals(AbstractUiContext.getMapDir())) { mapMenuItem.setSelected(true); } mapMenuItem.addActionListener( e -> { try { frame.updateMap(skins.get(key)); if (uiContext.getMapData().getHasRelief()) { showMapDetails.setSelected(true); } showMapDetails.setEnabled(uiContext.getMapData().getHasRelief()); } catch (final Exception exception) { log.log(Level.SEVERE, "Error Changing Map Skin2", exception); } }); } }
Example 6
Source File: ActionMappings.java From netbeans with Apache License 2.0 | 5 votes |
@Messages("ActionMappings.globalVar=Reference IDE Global Variable") private static JMenu createGlobalVarSubmenu(JTextComponent area) { JMenu menu = new JMenu(); menu.setText(ActionMappings_globalVar()); Map<String, String> vars = DefaultReplaceTokenProvider.readVariables(); boolean hasAny = false; for (Map.Entry<String, String> ent : vars.entrySet()) { hasAny = true; menu.add(new UseGlobalVarAction(area, ent.getKey())); } if (!hasAny) { menu.setEnabled(false); } return menu; }
Example 7
Source File: ActiveBrowserAction.java From netbeans with Apache License 2.0 | 5 votes |
@NbBundle.Messages({ "ActiveBrowserAction.missingProject=Project does not have any browser selected" }) private void updateButton(ProjectBrowserProvider pbp) { JButton tb = toolbarButton; if (tb != null) { if (lastWebBrowser != null) { lastWebBrowser.removeChangeListener(ideBrowserChangeListener); lastWebBrowser = null; } if (pbp == null) { tb.setIcon(badgeWithArrowIcon(ImageUtilities.loadImage(isSmallToolbarIcon() ? DISABLED_SMALL : DISABLED_LARGE))); // NOI18N tb.setDisabledIcon(badgeWithArrowIcon(ImageUtilities.loadImage(isSmallToolbarIcon() ? DISABLED_SMALL : DISABLED_LARGE))); // NOI18N tb.setToolTipText(null); } else { WebBrowser wb = pbp.getActiveBrowser(); Image im; if (wb != null) { im = wb.getIconImage(isSmallToolbarIcon()); tb.setToolTipText(BrowserUISupport.getLongDisplayName(wb)); wb.addChangeListener(ideBrowserChangeListener); } else { im = ImageUtilities.loadImage(isSmallToolbarIcon() ? GENERIC_SMALL : GENERIC_LARGE); // NOI18N tb.setToolTipText(Bundle.ActiveBrowserAction_missingProject()); } tb.setIcon(badgeWithArrowIcon(im)); lastWebBrowser = wb; } tb.setEnabled(pbp != null); } JMenu ma = menuAction; if (ma != null) { ma.setEnabled(pbp != null); } }
Example 8
Source File: DynamicMenu.java From netbeans with Apache License 2.0 | 5 votes |
protected static void enableMenu (JMenu menu) { boolean enabled = false; for (int i = 0; i < menu.getItemCount(); ++i) { JMenuItem item = menu.getItem(i); if (item != null && item.isEnabled()) { enabled = true; break; } } menu.setEnabled(enabled); }
Example 9
Source File: DynamicMenu.java From netbeans with Apache License 2.0 | 5 votes |
protected static void enableMenu (JMenu menu) { boolean enabled = false; for (int i = 0; i < menu.getItemCount(); ++i) { JMenuItem item = menu.getItem(i); if (item != null && item.isEnabled()) { enabled = true; break; } } menu.setEnabled(enabled); }
Example 10
Source File: ShelveChangesMenu.java From netbeans with Apache License 2.0 | 5 votes |
private void enableMenu (JMenu menu) { boolean enabled = false; for (int i = 0; i < menu.getItemCount(); ++i) { JMenuItem item = menu.getItem(i); if (item != null && item.isEnabled()) { enabled = true; break; } } menu.setEnabled(enabled); }
Example 11
Source File: DynamicMenu.java From netbeans with Apache License 2.0 | 5 votes |
protected static void enableMenu (JMenu menu) { boolean enabled = false; for (int i = 0; i < menu.getItemCount(); ++i) { JMenuItem item = menu.getItem(i); if (item != null && item.isEnabled()) { enabled = true; break; } } menu.setEnabled(enabled); }
Example 12
Source File: MenuManager.java From jeveassets with GNU General Public License v2.0 | 5 votes |
public static void update(final Program program, final Class<?> clazz) { MenuManager<?> menuManager = MANAGERS.get(clazz); if (menuManager != null) { menuManager.updateMainTableMenu(); } else { //No table menu JMenu jMenu = program.getMainWindow().getMenu().getTableMenu(); jMenu.removeAll(); jMenu.setEnabled(false); } }
Example 13
Source File: AmidstMenuBuilder.java From amidst with GNU General Public License v3.0 | 5 votes |
private JMenu create_World() { JMenu result = new JMenu("World"); result.setEnabled(false); result.setMnemonic(KeyEvent.VK_W); // @formatter:off Menus.item(result, actions::goToCoordinate, "Go to Coordinate ...", KeyEvent.VK_C, MenuShortcuts.GO_TO_COORDINATE); Menus.item(result, actions::goToSpawn, "Go to World Spawn", KeyEvent.VK_S, MenuShortcuts.GO_TO_WORLD_SPAWN); Menus.item(result, actions::goToStronghold, "Go to Stronghold ...", KeyEvent.VK_H, MenuShortcuts.GO_TO_STRONGHOLD); Menus.item(result, actions::goToPlayer, "Go to Player ...", KeyEvent.VK_P, MenuShortcuts.GO_TO_PLAYER); result.addSeparator(); Menus.item(result, actions::zoomIn, "Zoom In", KeyEvent.VK_I, MenuShortcuts.ZOOM_IN); Menus.item(result, actions::zoomOut, "Zoom Out", KeyEvent.VK_O, MenuShortcuts.ZOOM_OUT); result.addSeparator(); savePlayerLocationsMenu = Menus.item(result, actions::savePlayerLocations, "Save Player Locations", KeyEvent.VK_V, MenuShortcuts.SAVE_PLAYER_LOCATIONS); savePlayerLocationsMenu.setEnabled(false); reloadPlayerLocationsMenu = Menus.item(result, actions::reloadPlayerLocations, "Reload Player Locations", KeyEvent.VK_R, MenuShortcuts.RELOAD_PLAYER_LOCATIONS); reloadPlayerLocationsMenu.setEnabled(false); Menus.item(result, actions::howCanIMoveAPlayer, "How Can I Move a Player?", KeyEvent.VK_M); result.addSeparator(); Menus.item(result, actions::copySeedToClipboard, "Copy Seed to Clipboard", KeyEvent.VK_B, MenuShortcuts.COPY_SEED_TO_CLIPBOARD); Menus.item(result, actions::takeScreenshot, "Take Screenshot ...", KeyEvent.VK_T, MenuShortcuts.TAKE_SCREENSHOT); result.addSeparator(); Menus.item(result, actions::openExportDialog, "Export Biomes to Image ...", KeyEvent.VK_X, MenuShortcuts.EXPORT_BIOMES); // @formatter:on return result; }
Example 14
Source File: HistoryMenu.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
/** * Fill the provided menu with one item per each history path. * * @param menu the menu to populate * @param resourceClass the class to get menu resources from */ public void populate (JMenu menu, Class<?> resourceClass) { history.feedMenu(menu, new ActionListener() { @Override public void actionPerformed (ActionEvent e) { try { final String name = e.getActionCommand().trim(); if (!name.isEmpty()) { PathTask pathTask = pathTaskClass.newInstance(); pathTask.setPath(Paths.get(name)); pathTask.execute(); } } catch (IllegalAccessException | InstantiationException ex) { logger.warn("Error in HistoryMenu " + ex, ex); } } }); // Resource injection ResourceMap resource = OmrGui.getApplication().getContext().getResourceMap(resourceClass); resource.injectComponents(menu); this.menu = menu; // Initial menu status menu.setEnabled(!history.isEmpty()); }
Example 15
Source File: AmidstMenuBuilder.java From amidst with GNU General Public License v3.0 | 5 votes |
private JMenu create_World() { JMenu result = new JMenu("World"); result.setEnabled(false); result.setMnemonic(KeyEvent.VK_W); // @formatter:off Menus.item(result, actions::goToCoordinate, "Go to Coordinate ...", KeyEvent.VK_C, MenuShortcuts.GO_TO_COORDINATE); Menus.item(result, actions::goToSpawn, "Go to World Spawn", KeyEvent.VK_S, MenuShortcuts.GO_TO_WORLD_SPAWN); Menus.item(result, actions::goToStronghold, "Go to Stronghold ...", KeyEvent.VK_H, MenuShortcuts.GO_TO_STRONGHOLD); Menus.item(result, actions::goToPlayer, "Go to Player ...", KeyEvent.VK_P, MenuShortcuts.GO_TO_PLAYER); result.addSeparator(); Menus.item(result, actions::zoomIn, "Zoom In", KeyEvent.VK_I, MenuShortcuts.ZOOM_IN); Menus.item(result, actions::zoomOut, "Zoom Out", KeyEvent.VK_O, MenuShortcuts.ZOOM_OUT); result.addSeparator(); savePlayerLocationsMenu = Menus.item(result, actions::savePlayerLocations, "Save Player Locations", KeyEvent.VK_V, MenuShortcuts.SAVE_PLAYER_LOCATIONS); savePlayerLocationsMenu.setEnabled(false); reloadPlayerLocationsMenu = Menus.item(result, actions::reloadPlayerLocations, "Reload Player Locations", KeyEvent.VK_R, MenuShortcuts.RELOAD_PLAYER_LOCATIONS); reloadPlayerLocationsMenu.setEnabled(false); Menus.item(result, actions::howCanIMoveAPlayer, "How Can I Move a Player?", KeyEvent.VK_M); result.addSeparator(); Menus.item(result, actions::copySeedToClipboard, "Copy Seed to Clipboard", KeyEvent.VK_B, MenuShortcuts.COPY_SEED_TO_CLIPBOARD); Menus.item(result, actions::takeScreenshot, "Take Screenshot ...", KeyEvent.VK_T, MenuShortcuts.TAKE_SCREENSHOT); result.addSeparator(); Menus.item(result, actions::openExportDialog, "Export Biomes to Image ...", KeyEvent.VK_X, MenuShortcuts.EXPORT_BIOMES); // @formatter:on return result; }
Example 16
Source File: SimpleGUI.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
/** This method refreshes the "file" menu. */ private Runner doRefreshFile() { if (wrap) return wrapMe(); try { wrap = true; filemenu.removeAll(); menuItem(filemenu, "New", 'N', 'N', doNew()); menuItem(filemenu, "Open...", 'O', 'O', doOpen()); if (!Util.onMac()) menuItem(filemenu, "Open Sample Models...", VK_ALT, 'O', doBuiltin()); else menuItem(filemenu, "Open Sample Models...", doBuiltin()); JMenu recentmenu; filemenu.add(recentmenu = new JMenu("Open Recent")); menuItem(filemenu, "Reload all", 'R', 'R', doReloadAll()); menuItem(filemenu, "Save", 'S', 'S', doSave()); if (Util.onMac()) menuItem(filemenu, "Save As...", VK_SHIFT, 'S', doSaveAs()); else menuItem(filemenu, "Save As...", 'A', doSaveAs()); menuItem(filemenu, "Close", 'W', 'W', doClose()); menuItem(filemenu, "Clear Temporary Directory", doClearTemp()); menuItem(filemenu, "Quit", 'Q', (Util.onMac() ? -1 : 'Q'), doQuit()); boolean found = false; for (StringPref p : new StringPref[] { Model0, Model1, Model2, Model3 }) { String name = p.get(); if (name.length() > 0) { found = true; menuItem(recentmenu, name, doOpenFile(name)); } } recentmenu.addSeparator(); menuItem(recentmenu, "Clear Menu", doClearRecent()); recentmenu.setEnabled(found); } finally { wrap = false; } return null; }
Example 17
Source File: SimpleGUI.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
/** This method refreshes the "Option" menu. */ private Runner doRefreshOption() { if (wrap) return wrapMe(); try { wrap = true; optmenu.removeAll(); addToMenu(optmenu, Welcome); optmenu.addSeparator(); addToMenu(optmenu, WarningNonfatal); addToMenu(optmenu, SubMemory, SubStack, VerbosityPref); optmenu.addSeparator(); addToMenu(optmenu, SyntaxDisabled); addToMenu(optmenu, FontSize); menuItem(optmenu, "Font: " + FontName.get() + "...", doOptFontname()); addToMenu(optmenu, TabSize); if (Util.onMac() || Util.onWindows()) menuItem(optmenu, "Use anti-aliasing: Yes", false); else addToMenu(optmenu, AntiAlias); addToMenu(optmenu, A4Preferences.LAF); optmenu.addSeparator(); addToMenu(optmenu, Solver); addToMenu(optmenu, SkolemDepth); JMenu cmMenu = addToMenu(optmenu, CoreMinimization); cmMenu.setEnabled(Solver.get() == SatSolver.MiniSatProverJNI); JMenu cgMenu = addToMenu(optmenu, CoreGranularity); cgMenu.setEnabled(Solver.get() == SatSolver.MiniSatProverJNI); addToMenu(optmenu, AutoVisualize, RecordKodkod); if (Version.experimental) { addToMenu(optmenu, Unrolls); addToMenu(optmenu, ImplicitThis, NoOverflow, InferPartialInstance); } } finally { wrap = false; } return null; }
Example 18
Source File: BlazeActions.java From constellation with Apache License 2.0 | 4 votes |
public BlazeActions() { panel = new JPanel(); panel.setLayout(new BorderLayout()); menuBar = new JMenuBar(); menuBar.setOpaque(true); menu = new JMenu(); menu.setIcon(ImageUtilities.loadImageIcon(BLAZE_ACTIONS_ICON, false)); menu.setToolTipText("Blaze Controls"); menu.addChangeListener(e -> { if (graph != null) { updateSliders(graph); } }); menu.setEnabled(false); final JMenuItem selectBlazesItem = new JMenuItem("Select Blazes"); selectBlazesItem.setIcon(ImageUtilities.loadImageIcon(SELECT_BLAZES_ICON, false)); selectBlazesItem.setActionCommand(SELECT_BLAZES_ACTION); selectBlazesItem.addActionListener(this); menu.add(selectBlazesItem); final JMenuItem deselectBlazesItem = new JMenuItem("Deselect Blazes"); deselectBlazesItem.setIcon(ImageUtilities.loadImageIcon(DESELECT_BLAZES_ICON, false)); deselectBlazesItem.setActionCommand(DESELECT_BLAZES_ACTION); deselectBlazesItem.addActionListener(this); menu.add(deselectBlazesItem); final JMenuItem addBlueBlazeItem = new JMenuItem("Add Blue Blazes"); addBlueBlazeItem.setIcon(ImageUtilities.loadImageIcon(ADD_BLUE_BLAZE_ICON, false)); addBlueBlazeItem.setActionCommand(ADD_BLUE_BLAZE_ACTION); addBlueBlazeItem.addActionListener(BlazeActions.this); menu.add(addBlueBlazeItem); final JMenuItem addRedBlazeItem = new JMenuItem("Add Red Blazes"); addRedBlazeItem.setIcon(ImageUtilities.loadImageIcon(ADD_RED_BLAZE_ICON, false)); addRedBlazeItem.setActionCommand(ADD_RED_BLAZE_ACTION); addRedBlazeItem.addActionListener(BlazeActions.this); menu.add(addRedBlazeItem); final JMenuItem addYellowBlazeItem = new JMenuItem("Add Yellow Blazes"); addYellowBlazeItem.setIcon(ImageUtilities.loadImageIcon(ADD_YELLOW_BLAZE_ICON, false)); addYellowBlazeItem.setActionCommand(ADD_YELLOW_BLAZE_ACTION); addYellowBlazeItem.addActionListener(BlazeActions.this); menu.add(addYellowBlazeItem); final JMenuItem colorBlazeItem = new JMenuItem("Add Custom Blazes"); colorBlazeItem.setIcon(ImageUtilities.loadImageIcon(ADD_CUSTOM_BLAZE_ICON, false)); colorBlazeItem.setActionCommand(ADD_CUSTOM_BLAZE_ACTION); colorBlazeItem.addActionListener(BlazeActions.this); menu.add(colorBlazeItem); final JMenuItem removeBlazeItem = new JMenuItem("Remove Blazes"); removeBlazeItem.setIcon(ImageUtilities.loadImageIcon(REMOVE_BLAZE_ICON, false)); removeBlazeItem.setActionCommand(REMOVE_BLAZES_ACTION); removeBlazeItem.addActionListener(BlazeActions.this); menu.add(removeBlazeItem); this.sizeSlider = new SliderMenuItem("Size"); sizeSlider.setValue((NbPreferences.forModule(GraphPreferenceKeys.class) .getInt(GraphPreferenceKeys.BLAZE_SIZE, GraphPreferenceKeys.BLAZE_SIZE_DEFAULT))); menu.add(sizeSlider); this.opacitySlider = new SliderMenuItem("Opacity"); opacitySlider.setValue((NbPreferences.forModule(GraphPreferenceKeys.class) .getInt(GraphPreferenceKeys.BLAZE_OPACITY, GraphPreferenceKeys.BLAZE_OPACITY_DEFAULT))); menu.add(opacitySlider); this.sliderChangeListener = e -> setBlazeProperties(sizeSlider.getValue() / 100f, opacitySlider.getValue() / 100f); sizeSlider.addChangeListener(sliderChangeListener); opacitySlider.addChangeListener(sliderChangeListener); menuBar.add(menu); panel.add(menuBar, BorderLayout.CENTER); GraphManager.getDefault().addGraphManagerListener(BlazeActions.this); }
Example 19
Source File: HopActions.java From constellation with Apache License 2.0 | 4 votes |
public HopActions() { panel = new JPanel(); panel.setLayout(new BorderLayout()); menuBar = new JMenuBar(); menuBar.setOpaque(true); menu = new JMenu(); menu.setIcon(HOP_OUT_ONE_ICON); menu.setToolTipText("Hop Controls"); menu.setEnabled(false); final JMenuItem hopOutHalfItem = new JMenuItem("Hop Out Half"); hopOutHalfItem.setIcon(HOP_OUT_HALF_ICON); hopOutHalfItem.setActionCommand(HOP_OUT_HALF_ACTION); hopOutHalfItem.addActionListener(HopActions.this); menu.add(hopOutHalfItem); final JMenuItem hopOutOneItem = new JMenuItem("Hop Out One"); hopOutOneItem.setIcon(HOP_OUT_ONE_ICON); hopOutOneItem.setActionCommand(HOP_OUT_ONE_ACTION); hopOutOneItem.addActionListener(HopActions.this); menu.add(hopOutOneItem); final JMenuItem hopOutFullItem = new JMenuItem("Hop Out Full"); hopOutFullItem.setIcon(HOP_OUT_FULL_ICON); hopOutFullItem.setActionCommand(HOP_OUT_FULL_ACTION); hopOutFullItem.addActionListener(HopActions.this); menu.add(hopOutFullItem); final JPanel directionPanel = new JPanel(); directionPanel.setLayout(new BoxLayout(directionPanel, BoxLayout.Y_AXIS)); directionPanel.setBorder(new TitledBorder("Direction")); outgoing = new JCheckBox("Outgoing", true); outgoing.setToolTipText("Hop Along Outgoing Transactions"); directionPanel.add(outgoing); incoming = new JCheckBox("Incoming", true); incoming.setToolTipText("Hop Along Incoming Transactions"); directionPanel.add(incoming); undirected = new JCheckBox("Undirected", true); undirected.setToolTipText("Hop Along Undirected Transactions"); directionPanel.add(undirected); final JPanel optionsPanel = new JPanel(); optionsPanel.setBorder(new EmptyBorder(10, 0, 0, 0)); optionsPanel.setLayout(new BorderLayout()); optionsPanel.add(directionPanel, BorderLayout.CENTER); menu.add(optionsPanel); menuBar.add(menu); panel.add(menuBar, BorderLayout.CENTER); GraphManager.getDefault().addGraphManagerListener(HopActions.this); }
Example 20
Source File: DimActions.java From constellation with Apache License 2.0 | 4 votes |
public DimActions() { panel = new JPanel(); panel.setLayout(new BorderLayout()); menuBar = new JMenuBar(); menuBar.setOpaque(true); menu = new JMenu(); menu.setIcon(ImageUtilities.loadImageIcon(DIM_ACTIONS_ICON, false)); menu.setToolTipText("Dim Controls"); menu.setEnabled(false); final JMenuItem dimSelectedItem = new JMenuItem("Dim Selected"); dimSelectedItem.setIcon(ImageUtilities.loadImageIcon(DIM_SELECTED_ICON, false)); dimSelectedItem.setActionCommand(DIM_SELECTED_ACTION); dimSelectedItem.addActionListener(DimActions.this); menu.add(dimSelectedItem); final JMenuItem dimUnselectedItem = new JMenuItem("Dim Unselected"); dimUnselectedItem.setIcon(ImageUtilities.loadImageIcon(DIM_UNSELECTED_ICON, false)); dimUnselectedItem.setActionCommand(DIM_UNSELECTED_ACTION); dimUnselectedItem.addActionListener(DimActions.this); menu.add(dimUnselectedItem); final JMenuItem dimAllItem = new JMenuItem("Dim All"); dimAllItem.setIcon(ImageUtilities.loadImageIcon(DIM_ALL_ICON, false)); dimAllItem.setActionCommand(DIM_ALL_ACTION); dimAllItem.addActionListener(DimActions.this); menu.add(dimAllItem); menu.add(new JSeparator(SwingConstants.HORIZONTAL)); final JMenuItem undimSelectedItem = new JMenuItem("Undim Selected"); undimSelectedItem.setIcon(ImageUtilities.loadImageIcon(UNDIM_SELECTED_ICON, false)); undimSelectedItem.setActionCommand(UNDIM_SELECTED_ACTION); undimSelectedItem.addActionListener(DimActions.this); menu.add(undimSelectedItem); final JMenuItem undimUnselectedItem = new JMenuItem("Undim Unselected"); undimUnselectedItem.setIcon(ImageUtilities.loadImageIcon(UNDIM_UNSELECTED_ICON, false)); undimUnselectedItem.setActionCommand(UNDIM_UNSELECTED_ACTION); undimUnselectedItem.addActionListener(DimActions.this); menu.add(undimUnselectedItem); final JMenuItem undimAllItem = new JMenuItem("Undim All"); undimAllItem.setIcon(ImageUtilities.loadImageIcon(UNDIM_ALL_ICON, false)); undimAllItem.setActionCommand(UNDIM_ALL_ACTION); undimAllItem.addActionListener(DimActions.this); menu.add(undimAllItem); menu.add(new JSeparator(SwingConstants.HORIZONTAL)); final JMenuItem selectDimmed = new JMenuItem("Select Dimmed"); selectDimmed.setIcon(ImageUtilities.loadImageIcon(SELECT_DIMMED_ICON, false)); selectDimmed.setActionCommand(SELECT_DIMMED_ACTION); selectDimmed.addActionListener(DimActions.this); menu.add(selectDimmed); final JMenuItem selectUndimmed = new JMenuItem("Select Undimmed"); selectUndimmed.setIcon(ImageUtilities.loadImageIcon(SELECT_UNDIMMED_ICON, false)); selectUndimmed.setActionCommand(SELECT_UNDIMMED_ACTION); selectUndimmed.addActionListener(DimActions.this); menu.add(selectUndimmed); menuBar.add(menu); panel.add(menuBar, BorderLayout.CENTER); GraphManager.getDefault().addGraphManagerListener(DimActions.this); }