Java 类javax.swing.event.MenuEvent 实例源码

项目:audiveris    文件:StepMenu.java   
@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);
        }
    }
}
项目:tda    文件:TDA.java   
/**
 * 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);
    }
}
项目:mars-sim    文件:MainWindowMenu.java   
/** 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));
    //marsViewerItem.setSelected(desktop.isToolWindowOpen(MarsViewer.NAME));

    showUnitBarItem.setSelected(desktop.getMainWindow().getUnitToolBar().isVisible());
    showToolBarItem.setSelected(desktop.getMainWindow().getToolToolBar().isVisible());

    musicVolumeItem.setValue(Math.round(desktop.getSoundPlayer().getMusicVolume() * 10F));
    musicVolumeItem.setEnabled(!desktop.getSoundPlayer().isMusicMute());
    effectVolumeItem.setValue(Math.round(desktop.getSoundPlayer().getEffectVolume() * 10F));
    effectVolumeItem.setEnabled(!desktop.getSoundPlayer().isSoundMute());
    musicMuteItem.setSelected(desktop.getSoundPlayer().isMusicMute());
    effectMuteItem.setSelected(desktop.getSoundPlayer().isSoundMute());
}
项目:mzmine2    文件:WindowsMenu.java   
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);
    }
项目:travelingsales    文件:DownloadMenu.java   
/**
 * Populate the sub-menus if needed.
 * ${@inheritDoc}.
 */
public void menuSelected(final MenuEvent arg0) {

    if (getSubElements().length > 0) {
        return;
    }
    synchronized (this) {
        if (loadSubMenus == null) {
            loadSubMenus = new SubMenuLoader(false);
            Future<?> submited = SUBMENULOADEREXECUTOR.submit(loadSubMenus);
            this.loadSubMenusFuture = submited;
            add(isLoadingMenuItem);
        }
    }

}
项目:wildfly-core    文件:TabsMenu.java   
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);
    }
}
项目:libreveris    文件:StepMenu.java   
@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);
        }
    }
}
项目:river-container    文件:Browser.java   
public void menuSelected(MenuEvent ev) {
    Object[] values;
    try {
        values = lookup.getFieldValues(tmpl, index, field.getName());
    } catch (Throwable t) {
        failure(t);
        return;
    }
    if (values == null) {
        addNone(menu);
        return;
    }
    for (int i = 0; i < values.length; i++) {
        JMenuItem item = new JMenuItem(values[i].toString());
        item.addActionListener(
                wrap(new Value(index, field, values[i])));
        menu.add(item);
    }
}
项目:MaxSim    文件:FigureWidget.java   
@Override
public void menuSelected(MenuEvent e) {
    if (menu.getItemCount() > 0) {
        // already built before
        return;
    }

    Set<Figure> set = figure.getPredecessorSet();
    if (successors) {
        set = figure.getSuccessorSet();
    }

    boolean first = true;
    for (Figure f : set) {
        if (f == figure) {
            continue;
        }

        if (first) {
            first = false;
        } else {
            menu.addSeparator();
        }

        Action go = diagramScene.createGotoAction(f);
        menu.add(go);

        JMenu preds = new JMenu("Nodes Above");
        preds.addMenuListener(new NeighborMenuListener(preds, f, false));
        menu.add(preds);

        JMenu succs = new JMenu("Nodes Below");
        succs.addMenuListener(new NeighborMenuListener(succs, f, true));
        menu.add(succs);
    }

    if (menu.getItemCount() == 0) {
        menu.add("(none)");
    }
}
项目:MaxSim    文件:FigureWidget.java   
@Override
public void menuSelected(MenuEvent e) {
    if (menu.getItemCount() > 0) {
        // already built before
        return;
    }

    Set<Figure> set = figure.getPredecessorSet();
    if (successors) {
        set = figure.getSuccessorSet();
    }

    boolean first = true;
    for (Figure f : set) {
        if (f == figure) {
            continue;
        }

        if (first) {
            first = false;
        } else {
            menu.addSeparator();
        }

        Action go = diagramScene.createGotoAction(f);
        menu.add(go);

        JMenu preds = new JMenu("Nodes Above");
        preds.addMenuListener(new NeighborMenuListener(preds, f, false));
        menu.add(preds);

        JMenu succs = new JMenu("Nodes Below");
        succs.addMenuListener(new NeighborMenuListener(succs, f, true));
        menu.add(succs);
    }

    if (menu.getItemCount() == 0) {
        menu.add("(none)");
    }
}
项目:openjdk-jdk10    文件:FigureWidget.java   
@Override
public void menuSelected(MenuEvent e) {
    if (menu.getItemCount() > 0) {
        // already built before
        return;
    }

    build(menu.getPopupMenu(), figure, FigureWidget.this, successors, diagramScene);
}
项目:geomapapp    文件:MapApp.java   
public void menuDeselected(MenuEvent e) {
    JMenu wm = (JMenu) e.getSource();

    // Cleans Windows if not visible
    if(wm.getText().matches("Windows") || wm.getText().matches("Window")) {
    wm.removeAll();
    System.gc();
    }

    /* When user first imports menu item the background is set to another color to catch user attention.
     * After user interaction will set the background color back.
     */
    if(wm.getText().matches("My Layer Sessions")) {
        JMenu selectSessionMenu = (JMenu) wm;
        try {
            JMenuItem selectSessionMenuChild = (JMenuItem) selectSessionMenu.getMenuComponent(0);
            Color currentColor = selectSessionMenu.getBackground();
            Color defaultColor = selectSessionMenuChild.getBackground();
            if(currentColor.getRed() + currentColor.getGreen() + currentColor.getBlue() == 586) {
                selectSessionMenu.setBackground(defaultColor);
                selectSessionMenu.revalidate(); 
        }
        } catch (Exception ex) {
            //don't do anything if menu component and cannot be cast as a JMenuItem 
            //(eg if it is a separator bar)
        }
    }
}
项目:openjdk9    文件:FigureWidget.java   
@Override
public void menuSelected(MenuEvent e) {
    if (menu.getItemCount() > 0) {
        // already built before
        return;
    }

    build(menu.getPopupMenu(), figure, FigureWidget.this, successors, diagramScene);
}
项目:audiveris    文件:PluginManager.java   
@Override
public void menuSelected (MenuEvent e)
{
    boolean enabled = StubsController.getCurrentStub() != null;

    for (int i = 0; i < menu.getItemCount(); i++) {
        JMenuItem menuItem = menu.getItem(i);

        // Beware of separators (for which returned menuItem is null)
        if (menuItem != null) {
            menuItem.setEnabled(enabled);
        }
    }
}
项目:audiveris    文件:DynamicMenu.java   
@Override
public void menuSelected (MenuEvent e)
{
    // Clean up the whole menu
    menu.removeAll();

    // Rebuild the whole list of menu items on the fly
    buildItems();
}
项目:audiveris    文件:NameSet.java   
/**
 * 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;
}
项目:javify    文件:BasicMenuUI.java   
/**
 * This method is called when menu is deselected. It clears selected index
 * in the selectionModel of the menu parent.
 *
 * @param e The MenuEvent.
 */
public void menuDeselected(MenuEvent e)
{
  JMenu menu = (JMenu) menuItem;
  if (menu.getParent() != null)
    {
      if (menu.isTopLevelMenu())
        ((JMenuBar) menu.getParent()).getSelectionModel().clearSelection();
      else
        ((JPopupMenu) menu.getParent()).getSelectionModel().clearSelection();
    }
}
项目:javify    文件:BasicMenuUI.java   
/**
 * This method is called when menu is selected.  It sets selected index
 * in the selectionModel of the menu parent.
 *
 * @param e The MenuEvent.
 */
public void menuSelected(MenuEvent e)
{
  JMenu menu = (JMenu) menuItem;
  if (menu.isTopLevelMenu())
    ((JMenuBar) menu.getParent()).setSelected(menu);
  else
    ((JPopupMenu) menu.getParent()).setSelected(menu);
}
项目:mars-sim    文件:NotificationMenu.java   
/** 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());
}
项目:thread-dump-analysis    文件:TDA.java   
/**
 * 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);
    }
}
项目:jvm-stm    文件:BasicMenuUI.java   
/**
 * This method is called when menu is deselected. It clears selected index
 * in the selectionModel of the menu parent.
 *
 * @param e The MenuEvent.
 */
public void menuDeselected(MenuEvent e)
{
  JMenu menu = (JMenu) menuItem;
  if (menu.getParent() != null)
    {
      if (menu.isTopLevelMenu())
        ((JMenuBar) menu.getParent()).getSelectionModel().clearSelection();
      else
        ((JPopupMenu) menu.getParent()).getSelectionModel().clearSelection();
    }
}
项目:jvm-stm    文件:BasicMenuUI.java   
/**
    * This method is called when menu is selected.  It sets selected index
    * in the selectionModel of the menu parent.
    *
    * @param e The MenuEvent.
    */
   public void menuSelected(MenuEvent e)
   {
     JMenu menu = (JMenu) menuItem;
     if (menu.isTopLevelMenu())
((JMenuBar) menu.getParent()).setSelected(menu);
     else
((JPopupMenu) menu.getParent()).setSelected(menu);
   }
项目:chatty    文件:MainGui.java   
@Override
public void menuSelected(MenuEvent e) {
    if (e.getSource() == menu.srlStreams) {
        ArrayList<String> popoutStreams = new ArrayList<>();
        for (Channel channel : channels.getPopoutChannels().keySet()) {
            popoutStreams.add(channel.getStreamName());
        }
        menu.updateSrlStreams(channels.getActiveTab().getStreamName(), popoutStreams);
    } else if (e.getSource() == menu.view) {
        menu.updateCount(highlightedMessages.getNewCount(),
                highlightedMessages.getDisplayedCount(),
                ignoredMessages.getNewCount(),
                ignoredMessages.getDisplayedCount());
    }
}
项目:mzmine2    文件:ExportPopUpMenu.java   
@Override
   public void menuSelected(final MenuEvent e) {

// Clear the menu
removeAll();

// get all project files
RawDataFile[] openFiles = MZmineCore.getProjectManager()
    .getCurrentProject().getDataFiles();
List<RawDataFile> visualizedFiles = Arrays.asList(visualizer
    .getRawDataFiles());

menuItemFiles = new Hashtable<JMenuItem, RawDataFile>();
for (final RawDataFile file : openFiles) {

    // if file is not part of plot, skip it
    if (!visualizedFiles.contains(file))
    continue;

    // add a menu item for file
    JMenuItem newItem = new JMenuItem(file.getName());

    // Handle item selection.
    newItem.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed(final ActionEvent event) {

        if (file != null) {
        visualizer.exportChromatogram(file);
        }
    }
    });

    menuItemFiles.put(newItem, file);
    add(newItem);
}

   }
项目:mzmine2    文件:RemoveFilePopupMenu.java   
/**
    * @see javax.swing.event.MenuListener#menuSelected(javax.swing.event.MenuEvent)
    */
   public void menuSelected(MenuEvent event) {

// Clear the menu
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 file is not part of plot, skip it
    if (!visualizedFiles.contains(file))
    continue;

    // add a menu item for file
    JMenuItem newItem = new JMenuItem(file.getName());
    newItem.addActionListener(this);
    menuItemFiles.put(newItem, file);
    add(newItem);
}

   }
项目:mzmine2    文件:AddFilePopupMenu.java   
/**
    * @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);
}

   }
项目:viewer    文件:HGVMenus.java   
public void menuSelected(MenuEvent e)
{
    boolean b = HGVKit.getCurrentView() != null;
    for (int i = 0; i < getMenuComponentCount(); i++)
    {
        Component c = getMenuComponent(i);
        if (/* b == true && */c instanceof JMenuItem)
        {
            Action a = ((JMenuItem) c).getAction();
            if (a != null) b = a.isEnabled();
        }
        c.setEnabled(b);
    }
}
项目:Chatty-Twitch-Client    文件:MainGui.java   
@Override
public void menuSelected(MenuEvent e) {
    if (e.getSource() == menu.srlStreams) {
        ArrayList<String> popoutStreams = new ArrayList<>();
        for (Channel channel : channels.getPopoutChannels().keySet()) {
            popoutStreams.add(channel.getStreamName());
        }
        menu.updateSrlStreams(channels.getActiveTab().getStreamName(), popoutStreams);
    } else if (e.getSource() == menu.view) {
        menu.updateCount(highlightedMessages.getNewCount(),
                highlightedMessages.getDisplayedCount(),
                ignoredMessages.getNewCount(),
                ignoredMessages.getDisplayedCount());
    }
}
项目:logdog    文件:ChartView.java   
@Override
public void menuSelected(MenuEvent evt) {
    updateActions();
    updateLogSourceMenuActions();
    if (evt.getSource() == mAboutMenu) {
        mAboutMenu.getAction().actionPerformed(new ActionEvent(ChartView.this, ActionEvent.ACTION_PERFORMED, ""));
    }
}
项目:jaamsim    文件:GUIFrame.java   
@Override
public void menuSelected(MenuEvent arg0) {
    if (!RenderManager.isGood()) { return; }

    ArrayList<Integer> windowIDs = RenderManager.inst().getOpenWindowIDs();
    for (int id : windowIDs) {
        String windowName = RenderManager.inst().getWindowName(id);
        this.add(new WindowSelector(id, windowName));
    }
}
项目:Folding-Map    文件:MainWindow.java   
@Override
public void menuSelected(MenuEvent me) {
    if (me.getSource() == menuEdit) {    
        //Update Undo and Redu MenuItems to include the action description.
        updateEditMenu();
    }
}
项目:ROPE    文件:RopeFrame.java   
@Override
public void menuSelected(MenuEvent event)
{
    JMenu menu = (JMenu)event.getSource();

    if(menu == editMenu)
    {
        currentChildFrame.updateEditMenu(editMenu);
    }
}
项目:emcalc    文件:EmCalcGUI.java   
public void menuSelected(MenuEvent e)
{
    int tabIndex = paneTab.getSelectedIndex();
    if(tabIndex >= 0 && !((EmCalcPanel)vectorTabs.get(tabIndex)).isLoaded())
    {
        menuitemOpenXML.setEnabled(true);
        menuitemSaveXML.setEnabled(true);
        menuitemReload.setEnabled(false);
    }
    if(tabIndex >= 0 && ((EmCalcPanel)vectorTabs.get(tabIndex)).isLoaded())
        menuitemReload.setEnabled(true);
    else
    if(vectorTabs.size() == 1)
        menuitemCloseAll.setEnabled(false);
}
项目:regexSearch    文件:MainWindow.java   
public void menuSelected(MenuEvent event)
{
    Object eventSource = event.getSource();
    for (Menu menu : Menu.values())
    {
        if (eventSource == menu.menu)
            menu.update();
    }
}
项目:cn1    文件:JMenuTest.java   
public void menuDeselected(MenuEvent e) {
    event = "deselected";
    src = e.getSource();
    if (debugOut) {
        System.out.println(event);
    }
}
项目:cn1    文件:JMenuTest.java   
public void menuSelected(MenuEvent e) {
    event = "selected";
    src = e.getSource();
    if (debugOut) {
        System.out.println(event);
    }
}
项目:JamVM-PH    文件:BasicMenuUI.java   
/**
 * This method is called when menu is deselected. It clears selected index
 * in the selectionModel of the menu parent.
 *
 * @param e The MenuEvent.
 */
public void menuDeselected(MenuEvent e)
{
  JMenu menu = (JMenu) menuItem;
  if (menu.getParent() != null)
    {
      if (menu.isTopLevelMenu())
        ((JMenuBar) menu.getParent()).getSelectionModel().clearSelection();
      else
        ((JPopupMenu) menu.getParent()).getSelectionModel().clearSelection();
    }
}
项目:JamVM-PH    文件:BasicMenuUI.java   
/**
    * This method is called when menu is selected.  It sets selected index
    * in the selectionModel of the menu parent.
    *
    * @param e The MenuEvent.
    */
   public void menuSelected(MenuEvent e)
   {
     JMenu menu = (JMenu) menuItem;
     if (menu.isTopLevelMenu())
((JMenuBar) menu.getParent()).setSelected(menu);
     else
((JPopupMenu) menu.getParent()).setSelected(menu);
   }
项目:libreveris    文件:PluginsManager.java   
@Override
public void menuSelected (MenuEvent e)
{
    boolean enabled = SheetsController.getCurrentSheet() != null;

    for (int i = 0; i < menu.getItemCount(); i++) {
        JMenuItem menuItem = menu.getItem(i);

        // Beware of separators (for which returned menuItem is null)
        if (menuItem != null) {
            menuItem.setEnabled(enabled);
        }
    }
}
项目:libreveris    文件:DynamicMenu.java   
@Override
public void menuSelected (MenuEvent e)
{
    // Clean up the whole menu
    menu.removeAll();

    // Rebuild the whole list of menu items on the fly
    buildItems();
}