当前位置: 首页>>代码示例>>Java>>正文


Java MenuEvent类代码示例

本文整理汇总了Java中javax.swing.event.MenuEvent的典型用法代码示例。如果您正苦于以下问题:Java MenuEvent类的具体用法?Java MenuEvent怎么用?Java MenuEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MenuEvent类属于javax.swing.event包,在下文中一共展示了MenuEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: menuSelected

import javax.swing.event.MenuEvent; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:17,代码来源:StepMenu.java

示例2: menuSelected

import javax.swing.event.MenuEvent; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:irockel,项目名称:tda,代码行数:12,代码来源:TDA.java

示例3: menuSelected

import javax.swing.event.MenuEvent; //导入依赖的package包/类
/** 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());
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:25,代码来源:MainWindowMenu.java

示例4: menuSelected

import javax.swing.event.MenuEvent; //导入依赖的package包/类
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);
    }
 
开发者ID:mzmine,项目名称:mzmine2,代码行数:21,代码来源:WindowsMenu.java

示例5: menuSelected

import javax.swing.event.MenuEvent; //导入依赖的package包/类
/**
 * 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);
        }
    }

}
 
开发者ID:xafero,项目名称:travelingsales,代码行数:20,代码来源:DownloadMenu.java

示例6: menuSelected

import javax.swing.event.MenuEvent; //导入依赖的package包/类
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);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:22,代码来源:TabsMenu.java

示例7: menuSelected

import javax.swing.event.MenuEvent; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:jlpoolen,项目名称:libreveris,代码行数:18,代码来源:StepMenu.java

示例8: menuSelected

import javax.swing.event.MenuEvent; //导入依赖的package包/类
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);
    }
}
 
开发者ID:apache,项目名称:river-container,代码行数:20,代码来源:Browser.java

示例9: menuSelected

import javax.swing.event.MenuEvent; //导入依赖的package包/类
@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)");
    }
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:41,代码来源:FigureWidget.java

示例10: menuSelected

import javax.swing.event.MenuEvent; //导入依赖的package包/类
@Override
public void menuSelected(MenuEvent e) {
    if (menu.getItemCount() > 0) {
        // already built before
        return;
    }

    build(menu.getPopupMenu(), figure, FigureWidget.this, successors, diagramScene);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:FigureWidget.java

示例11: menuDeselected

import javax.swing.event.MenuEvent; //导入依赖的package包/类
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)
		}
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:29,代码来源:MapApp.java

示例12: menuSelected

import javax.swing.event.MenuEvent; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:15,代码来源:PluginManager.java

示例13: menuSelected

import javax.swing.event.MenuEvent; //导入依赖的package包/类
@Override
public void menuSelected (MenuEvent e)
{
    // Clean up the whole menu
    menu.removeAll();

    // Rebuild the whole list of menu items on the fly
    buildItems();
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:10,代码来源:DynamicMenu.java

示例14: feedMenu

import javax.swing.event.MenuEvent; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:37,代码来源:NameSet.java

示例15: menuDeselected

import javax.swing.event.MenuEvent; //导入依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:18,代码来源:BasicMenuUI.java


注:本文中的javax.swing.event.MenuEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。