當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。