javax.swing.event.MenuEvent Java Examples
The following examples show how to use
javax.swing.event.MenuEvent.
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: TabsMenu.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public void menuSelected(MenuEvent e) { TabsMenu.this.removeAll(); ExploreNodeAction exploreAction = new ExploreNodeAction(cliGuiCtx); JMenuItem exploreSelectedNode = new JMenuItem(exploreAction); exploreSelectedNode.setMnemonic(KeyEvent.VK_E); if ((exploreAction.getSelectedNode() == null) || exploreAction.getSelectedNode().isLeaf()) { exploreSelectedNode.setEnabled(false); } add(exploreSelectedNode); addSeparator(); JTabbedPane tabs = cliGuiCtx.getTabs(); for (int i=0; i < tabs.getTabCount(); i++) { GoToTabAction action = new GoToTabAction(i, tabs.getTitleAt(i)); JMenuItem item = new JMenuItem(action); item.setToolTipText(tabs.getToolTipTextAt(i)); add(item); } }
Example #2
Source File: StepMenu.java From libreveris with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void menuSelected (MenuEvent e) { Sheet sheet = SheetsController.getCurrentSheet(); boolean isIdle = (sheet != null) && (sheet.getCurrentStep() == null); for (int i = 0; i < menu.getItemCount(); i++) { JMenuItem menuItem = menu.getItem(i); // Adjust the status for each step if (menuItem instanceof StepItem) { StepItem item = (StepItem) menuItem; item.displayState(sheet, isIdle); } } }
Example #3
Source File: RecentFilesMenu.java From gcs with Mozilla Public License 2.0 | 6 votes |
@Override public void menuSelected(MenuEvent event) { Preferences prefs = Preferences.getInstance(); int lastRecentFilesUpdateCounter = prefs.getLastRecentFilesUpdateCounter(); if (mLastSeenRecentFilesUpdateCounter != lastRecentFilesUpdateCounter) { mLastSeenRecentFilesUpdateCounter = lastRecentFilesUpdateCounter; removeAll(); List<Path> list = new ArrayList<>(); for (Path path : prefs.getRecentFiles()) { if (Files.isReadable(path)) { list.add(path); add(new JMenuItem(new OpenDataFileCommand(PathUtils.getLeafName(path, false), path))); if (list.size() == Preferences.MAX_RECENT_FILES) { break; } } } prefs.setRecentFiles(list); if (!list.isEmpty()) { addSeparator(); } JMenuItem item = new JMenuItem(ClearRecentFilesMenuCommand.INSTANCE); ClearRecentFilesMenuCommand.INSTANCE.adjust(); add(item); } }
Example #4
Source File: WindowsMenu.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
public void menuSelected(MenuEvent event) { // Remove all previous items while (getItemCount() > 2) remove(2); int windowsAdded = 0; // Create a menu item for each window for (Frame window : Frame.getFrames()) { if (window.isVisible()) { FrameMenuItem newItem = new FrameMenuItem(window, this); add(newItem); windowsAdded++; } } // Disable the Close all button if we only have the main window closeAllMenuItem.setEnabled(windowsAdded > 1); }
Example #5
Source File: StepMenu.java From audiveris with GNU Affero General Public License v3.0 | 6 votes |
@Override public void menuSelected (MenuEvent e) { SheetStub stub = StubsController.getCurrentStub(); boolean isIdle = (stub != null) && (stub.getCurrentStep() == null); for (int i = 0; i < menu.getItemCount(); i++) { JMenuItem menuItem = menu.getItem(i); // Adjust the status for each step if (menuItem instanceof StepItem) { StepItem item = (StepItem) menuItem; item.displayState(stub, isIdle); } } }
Example #6
Source File: MainWindowMenu.java From mars-sim with GNU General Public License v3.0 | 6 votes |
/** MenuListener method overriding. */ @Override public final void menuSelected(MenuEvent event) { MainDesktopPane desktop = mainWindow.getDesktop(); marsNavigatorItem.setSelected(desktop.isToolWindowOpen(NavigatorWindow.NAME)); searchToolItem.setSelected(desktop.isToolWindowOpen(SearchWindow.NAME)); timeToolItem.setSelected(desktop.isToolWindowOpen(TimeWindow.NAME)); monitorToolItem.setSelected(desktop.isToolWindowOpen(MonitorWindow.NAME)); missionToolItem.setSelected(desktop.isToolWindowOpen(MissionWindow.NAME)); settlementToolItem.setSelected(desktop.isToolWindowOpen(SettlementWindow.NAME)); scienceToolItem.setSelected(desktop.isToolWindowOpen(ScienceWindow.NAME)); resupplyToolItem.setSelected(desktop.isToolWindowOpen(ResupplyWindow.NAME)); commanderDashboardItem.setSelected(desktop.isToolWindowOpen(CommanderWindow.NAME)); showUnitBarItem.setSelected(desktop.getMainWindow().getUnitToolBar().isVisible()); showToolBarItem.setSelected(desktop.getMainWindow().getToolToolBar().isVisible()); musicVolumeSlider.setValue((int) Math.round(soundPlayer.getMusicVolume() * 10)); musicVolumeSlider.setEnabled(!soundPlayer.isMusicMute()); effectVolumeSlider.setValue((int) Math.round(soundPlayer.getEffectVolume() * 10)); effectVolumeSlider.setEnabled(!soundPlayer.isSoundMute()); musicMuteItem.setSelected(soundPlayer.isMusicMute()); effectMuteItem.setSelected(soundPlayer.isSoundMute()); }
Example #7
Source File: AddFilePopupMenu.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
/** * @see javax.swing.event.MenuListener#menuSelected(javax.swing.event.MenuEvent) */ public void menuSelected(MenuEvent event) { // remove all menu items removeAll(); // get all project files RawDataFile[] openFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles(); List<RawDataFile> visualizedFiles = Arrays.asList(visualizer.getRawDataFiles()); menuItemFiles = new Hashtable<JMenuItem, RawDataFile>(); for (RawDataFile file : openFiles) { // if this file is already added, skip it if (visualizedFiles.contains(file)) continue; // add a menu item for each file JMenuItem newItem = new JMenuItem(file.getName()); newItem.addActionListener(this); menuItemFiles.put(newItem, file); add(newItem); } }
Example #8
Source File: NameSet.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
/** * Feed a menu with the dynamic content of this NameSet. * * @param menu the menu to be fed, if null it is allocated by this method * @param itemListener the listener to be called on item selection * @return the menu properly dynamized */ public JMenu feedMenu (JMenu menu, final ActionListener itemListener) { final JMenu finalMenu = (menu != null) ? menu : new JMenu(setName); MenuListener menuListener = new AbstractMenuListener() { @Override public void menuSelected (MenuEvent e) { // Clean up the whole menu finalMenu.removeAll(); // Rebuild the whole list of menu items on the fly synchronized (NameSet.this) { for (String f : names) { JMenuItem menuItem = new JMenuItem(f); menuItem.addActionListener(itemListener); finalMenu.add(menuItem); } } } }; // Listener to menu selection, to modify content on-the-fly finalMenu.addMenuListener(menuListener); return finalMenu; }
Example #9
Source File: DynamicMenu.java From audiveris with GNU Affero General Public License v3.0 | 5 votes |
@Override public void menuSelected (MenuEvent e) { // Clean up the whole menu menu.removeAll(); // Rebuild the whole list of menu items on the fly buildItems(); }
Example #10
Source File: TDA.java From tda with GNU Lesser General Public License v2.1 | 5 votes |
/** * check file menu */ public void menuSelected(MenuEvent e) { JMenu source = (JMenu) e.getSource(); if((source != null) && "File".equals(source.getText())) { // close menu item only active, if something is selected. getMainMenu().getCloseMenuItem().setEnabled(tree.getSelectionPath() != null); getMainMenu().getCloseToolBarButton().setEnabled(tree.getSelectionPath() != null); } }
Example #11
Source File: LibraryMenu.java From gcs with Mozilla Public License 2.0 | 5 votes |
@Override public void menuSelected(MenuEvent event) { removeAll(); for (Library lib : Library.LIBRARIES) { if (lib != Library.USER) { LibraryUpdateCommand item = new LibraryUpdateCommand(lib); item.adjust(); add(new JMenuItem(item)); } add(new JMenuItem(new ShowLibraryFolderCommand(lib))); addSeparator(); } add(new JMenuItem(ChangeLibraryLocationsCommand.INSTANCE)); }
Example #12
Source File: NotificationMenu.java From mars-sim with GNU General Public License v3.0 | 5 votes |
/** MenuListener method overriding. */ @Override public final void menuSelected(MenuEvent event) { //MainDesktopPane desktop = mainWindow.getDesktop(); //notificationItem.setSelected(desktop.getMainWindow().getNotification()); //volumeItem.setValue(Math.round(desktop.getSoundPlayer().getVolume() * 10F)); //volumeItem.setEnabled(!desktop.getSoundPlayer().isMute()); //muteItem.setSelected(desktop.getSoundPlayer().isMute()); }
Example #13
Source File: MainFrame.java From zxpoly with GNU General Public License v3.0 | 5 votes |
private void menuEditMenuSelected(javax.swing.event.MenuEvent evt) { this.toolsButtonGroup.clearSelection(); this.menuEditSelectArea.setEnabled(this.mainEditor.hasData()); this.menuEditPasteImage.setEnabled(GfxUtils.doesClipboardHasImage()); this.menuEditCopySelectedBaseAsImage.setEnabled(this.mainEditor.hasSelectedArea()); this.menuEditCopySelectedZxPolyAsImage.setEnabled(this.mainEditor.hasSelectedArea()); }
Example #14
Source File: ActionMenu.java From consulo with Apache License 2.0 | 5 votes |
@Override public void menuSelected(MenuEvent e) { if (isTopMenuBarAfterOpenJDKMemLeakFix()) { myMenuComponents = null; } else { fillMenu(ActionMenu.this); } }
Example #15
Source File: MainForm.java From zxpoly with GNU General Public License v3.0 | 5 votes |
private void menuFileMenuSelected(final MenuEvent evt) { boolean hasChangedDisk = false; for (int i = 0; i < 4; i++) { final TrDosDisk disk = this.board.getBetaDiskInterface().getDiskInDrive(i); hasChangedDisk |= (disk != null && disk.isChanged()); } this.menuFileFlushDiskChanges.setEnabled(hasChangedDisk); }
Example #16
Source File: DynamicMenuEnabler.java From gcs with Mozilla Public License 2.0 | 5 votes |
@Override public void menuSelected(MenuEvent event) { JMenu menu = (JMenu) event.getSource(); for (Component component : menu.getMenuComponents()) { if (component instanceof JMenuItem) { JMenuItem item = (JMenuItem) component; Action action = item.getAction(); if (action instanceof Command) { ((Command) action).adjust(); } } } }
Example #17
Source File: ActionMenu.java From consulo with Apache License 2.0 | 5 votes |
@Override public void menuCanceled(MenuEvent e) { if (isTopMenuBarAfterOpenJDKMemLeakFix()) { myMenuComponents = new Component[]{myStubItem}; } else { clearItems(); } }
Example #18
Source File: DynamicMenu.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void menuSelected (MenuEvent e) { // Clean up the whole menu menu.removeAll(); // Rebuild the whole list of menu items on the fly buildItems(); }
Example #19
Source File: ExportPopUpMenu.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
@Override public void menuDeselected(final MenuEvent e) { // do nothing }
Example #20
Source File: DynamicMenu.java From libreveris with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void menuCanceled (MenuEvent e) { }
Example #21
Source File: MainFrame.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
private void menuFileMenuCanceled(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_menuFileMenuCanceled enableAllMenuItems(); }
Example #22
Source File: AbstractMenuListener.java From audiveris with GNU Affero General Public License v3.0 | 4 votes |
@Override public void menuCanceled (MenuEvent e) { }
Example #23
Source File: ExportPopUpMenu.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
@Override public void menuCanceled(final MenuEvent e) { // do nothing }
Example #24
Source File: MainWindowMenu.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void menuDeselected(MenuEvent event) { }
Example #25
Source File: AddFilePopupMenu.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
/** * @see javax.swing.event.MenuListener#menuCanceled(javax.swing.event.MenuEvent) */ public void menuCanceled(MenuEvent arg0) { // do nothing }
Example #26
Source File: AbstractMenuListener.java From audiveris with GNU Affero General Public License v3.0 | 4 votes |
@Override public void menuDeselected (MenuEvent e) { }
Example #27
Source File: MainFrame.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
private void menuEditMenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_menuEditMenuSelected final TabTitle title = this.getFocusedTab(); updateMenuItemsForProvider(title == null ? null : title.getProvider()); this.menuEditShowTreeContextMenu.setEnabled(this.explorerTree.hasSelectedItem()); }
Example #28
Source File: PluginsManager.java From libreveris with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void menuDeselected (MenuEvent e) { }
Example #29
Source File: LibraryMenu.java From gcs with Mozilla Public License 2.0 | 4 votes |
@Override public void menuCanceled(MenuEvent event) { // Nothing to do. }
Example #30
Source File: ExportMenu.java From gcs with Mozilla Public License 2.0 | 4 votes |
@Override public void menuSelected(MenuEvent event) { removeAll(); boolean shouldEnable = Command.getTarget(SheetDockable.class) != null; ExportToGURPSCalculatorCommand.INSTANCE.setEnabled(shouldEnable); ExportToPDFCommand.INSTANCE.setEnabled(shouldEnable); ExportToPNGCommand.INSTANCE.setEnabled(shouldEnable); add(ExportToGURPSCalculatorCommand.INSTANCE); add(ExportToPDFCommand.INSTANCE); add(ExportToPNGCommand.INSTANCE); boolean needSep = true; for (Library lib : Library.LIBRARIES) { List<Command> cmds = new ArrayList<>(); Path dir = lib.getPath().resolve("Output Templates"); if (Files.isDirectory(dir)) { // IMPORTANT: On Windows, calling any of the older methods to list the contents of a // directory results in leaving state around that prevents future move & delete // operations. Only use this style of access for directory listings to avoid that. try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) { for (Path path : stream) { cmds.add(new ExportToTextTemplateCommand(path, lib)); } } catch (IOException exception) { Log.error(exception); } cmds.sort((c1, c2) -> NumericComparator.caselessCompareStrings(PathUtils.getLeafName(c1.getTitle(), true), PathUtils.getLeafName(c2.getTitle(), true))); } if (!cmds.isEmpty()) { if (needSep) { addSeparator(); needSep = false; } JMenu menu = new JMenu(String.format(I18n.Text("%s Output Templates"), lib.getTitle())); for (Command cmd : cmds) { cmd.setEnabled(shouldEnable); menu.add(cmd); } add(menu); } } }