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


Java JMenu.getItemCount方法代码示例

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


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

示例1: updateMenu

import javax.swing.JMenu; //导入方法依赖的package包/类
private void updateMenu (JMenu menu) {
        ActionProvider provider = getEngine().getActionProvider();
        Map context = getEngine().getContextProvider().getContext();
        String containerCtx = (String) menu.getClientProperty(KEY_CONTAINERCONTEXT);
        boolean isDynamic = getEngine().getContainerProvider().isDynamicContext(
            ContainerProvider.TYPE_MENU, containerCtx);
        
        String[] actions = provider.getActionNames(containerCtx);
//        System.err.println("Updating menu " + containerCtx + "actions: " + Arrays.asList(actions));
        
        int count = menu.getItemCount();
//        System.err.println("Item count = " + count);
        //XXX for dynamic menus, we'll need to compare the contents of the
        //menu with the list of strings, and add/prune
        
        for (int i=0; i < count; i++) {
            JMenuItem item = menu.getItem(i);
            if (item != null) {
                String action = (String) item.getClientProperty (KEY_ACTION);
                configureMenuItem (item, containerCtx, action, provider, context);
            }
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:AbstractMenuFactory.java

示例2: addProp

import javax.swing.JMenu; //导入方法依赖的package包/类
protected void addProp(JMenu menu, final String propName, boolean sort) {
  // Ignore any null propNames
  if (propName == null) {
    return;
  }

  final JMenuItem item = new JMenuItem(propName);
  item.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e) {
      insertPropertyName(propName);
    }});
  if (sort) {
    int pos = -1;
    for (int i = 0; i < menu.getItemCount() && pos < 0; i++) {
      if (propName.compareTo(menu.getItem(i).getText()) <= 0) {
        pos = i;
      }
    }
    menu.add(item, pos);
  }
  else {
    menu.add(item);
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:25,代码来源:BeanShellExpressionConfigurer.java

示例3: addMenuItems

import javax.swing.JMenu; //导入方法依赖的package包/类
/** 
 * Adds to a given menu all the items of another menu.
 * The submenu may be {@code null}, in which case nothing is added 
 * @param submenu the menu to be added to the popup menu;
 * will be destroyed as a consequence of this method call
 */
final public void addMenuItems(JMenu submenu) {
    if (submenu != null && submenu.getItemCount() > 0) {
        // as we move items from the submenu to the main menu
        // the submenu gets modified
        while (submenu.getItemCount() > 0) {
            JMenuItem item = submenu.getItem(0);
            if (item == null) {
                submenu.remove(0);
                addSeparator();
            } else {
                add(item);
            }
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:22,代码来源:MyJMenu.java

示例4: doCheckPatternsMenuItems

import javax.swing.JMenu; //导入方法依赖的package包/类
public final static void doCheckPatternsMenuItems(final JMenu objPjMenu, final PatternsFileJCheckBoxMenuItem objPpatternsFileJCheckBoxMenuItem) {

		if (objPjMenu != null) {
			final int intLmenuItemsNumber = objPjMenu.getItemCount();

			for (int intLitemIndex = 0; intLitemIndex < intLmenuItemsNumber; intLitemIndex++) {
				final JMenuItem objLjMenuItem = objPjMenu.getItem(intLitemIndex);
				if (objLjMenuItem instanceof PatternsFileJCheckBoxMenuItem) {
					final PatternsFileJCheckBoxMenuItem objLpatternsFileJCheckBoxMenuItem = (PatternsFileJCheckBoxMenuItem) objLjMenuItem;
					if (objLpatternsFileJCheckBoxMenuItem.equals(objPpatternsFileJCheckBoxMenuItem)) {
						objLpatternsFileJCheckBoxMenuItem.select(true);
					}
				} else if (objLjMenuItem instanceof JMenu) {
					FileActions.doCheckPatternsMenuItems((JMenu) objLjMenuItem, objPpatternsFileJCheckBoxMenuItem);
				}
			}
		}
	}
 
开发者ID:jugglemaster,项目名称:JuggleMasterPro,代码行数:19,代码来源:FileActions.java

示例5: createMainMenuBar

import javax.swing.JMenu; //导入方法依赖的package包/类
public static JMenuBar createMainMenuBar(List<XML_Menu> menuLayers) {
	JMenuBar mainMenuBar = new JMenuBar();
	for (XML_Menu sub_menu : menuLayers) {
		if ( mapApp.start != null ) {
			mapApp.start.setText("Initializing " + sub_menu.name + " Menu...");
		}
		if ( sub_menu.proj.toLowerCase().indexOf(MapApp.CURRENT_PROJECTION.toLowerCase()) != -1 ) {
			JMenu subMenu = createMenu(sub_menu);
			if (subMenu.getItemCount() != 0)
				mainMenuBar.add(subMenu);
				subMenu.addMenuListener(mapApp.listener);
		}
	}
	if ( mapApp != null && mapApp.start != null ) {
		mapApp.start.setText("Initializing GUI");
	}
	return mainMenuBar;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:19,代码来源:XML_Menu.java

示例6: enableMenu

import javax.swing.JMenu; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:DynamicMenu.java

示例7: enableMenu

import javax.swing.JMenu; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ShelveChangesMenu.java

示例8: menuItems

import javax.swing.JMenu; //导入方法依赖的package包/类
List<JMenuItem> menuItems() {
    List<JMenuItem> menus = new ArrayList();
    
    if (plugins != null) for (ProfilerPlugin plugin : plugins) {
        try {
            JMenu menu = new JMenu(plugin.getName());
            plugin.createMenu(menu);
            if (menu.getItemCount() > 0) menus.add(menu);
        } catch (Throwable t) {
            handleThrowable(plugin, t);
        }
    }
    
    return menus;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:ProfilerPlugins.java

示例9: addJMenuItemComponent

import javax.swing.JMenu; //导入方法依赖的package包/类
/**
 * This method can be used in order to add an individual JMmenuItem at a specified index position of the given menu.
 *
 * @param menu2add the menu2add
 * @param myMenuItemComponent the my menu item component
 * @param indexPosition the index position
 */
public void addJMenuItemComponent(JMenu menu2add, JComponent myMenuItemComponent, int indexPosition) {
	int nElements = menu2add.getItemCount();
	if (indexPosition > (nElements - 1)) {
		this.addJMenuItemComponent(menu2add, myMenuItemComponent);
	} else {
		menu2add.add(myMenuItemComponent, indexPosition);
		this.validate();
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:17,代码来源:MainWindow.java

示例10: buildGlobalMenu

import javax.swing.JMenu; //导入方法依赖的package包/类
/**
 * Create a menu of Global Properties recorded in this module, based on
 * the module build structure
 */

protected void buildGlobalMenu(JMenu parentMenu, AbstractBuildable target, boolean useParentMenu) {
  final List<Buildable> buildables = target.getBuildables();
  String menuName = ConfigureTree.getConfigureName(target.getClass());
  if (target instanceof AbstractConfigurable) {
    final String n = ((AbstractConfigurable) target).getConfigureName();
    if (n != null && n.length() > 0) {
      menuName += " " + n;
    }
  }
  final JMenu myMenu = new JMenu(menuName);

  final List<String> propNames = target.getPropertyNames();
  for (String propName : propNames) {
    addProp(useParentMenu ? parentMenu : myMenu, propName, true);
  }

  for (Buildable b : buildables) {
    if (b instanceof AbstractConfigurable) {
      // Remove 'filler' menu levels due to intermediate holding components
      final boolean useParent = (b instanceof GlobalProperties || b instanceof Board ||b instanceof ZonedGrid);
      buildGlobalMenu(useParentMenu ? parentMenu : myMenu, (AbstractConfigurable) b, useParent);
    }
    else if (b instanceof BoardPicker) {
      buildGlobalMenu(myMenu,(AbstractBuildable) b, true);
    }
  }

  if (! useParentMenu & myMenu.getItemCount() > 0) {
    MenuScroller.setScrollerFor(myMenu, getMaxScrollItems(), 100);
    int pos = -1;
    for (int i = 0; i < parentMenu.getItemCount() && pos < 0; i++) {
      if (myMenu.getText().compareTo(parentMenu.getItem(i).getText()) <= 0) {
        pos = i;
      }
    }
    parentMenu.add(myMenu, pos);
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:44,代码来源:BeanShellExpressionConfigurer.java

示例11: addSubmenu

import javax.swing.JMenu; //导入方法依赖的package包/类
/** 
 * Adds a submenu with all the items of another menu.
 * Precedes the new menu with a separator if it is nonempty.
 * The submenu may be {@code null}, in which case nothing is added 
 * @param submenu the menu to be added to the popup menu;
 * will be destroyed as a consequence of this method call
 */
final public void addSubmenu(JMenu submenu) {
    if (submenu != null && submenu.getItemCount() > 0) {
        // add a separator if this is not the first submenu
        if (getItemCount() > 0) {
            addSeparator();
        }
        addMenuItems(submenu);
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:17,代码来源:MyJMenu.java

示例12: doUncheckPatternsMenuItems

import javax.swing.JMenu; //导入方法依赖的package包/类
final public static void doUncheckPatternsMenuItems(final JMenu objPjMenu) {
	if (objPjMenu != null) {
		final int intLmenuItemsNumber = objPjMenu.getItemCount();

		for (int intLitemIndex = 0; intLitemIndex < intLmenuItemsNumber; intLitemIndex++) {
			final JMenuItem objLjMenuItem = objPjMenu.getItem(intLitemIndex);
			if (objLjMenuItem instanceof PatternsFileJCheckBoxMenuItem) {
				((PatternsFileJCheckBoxMenuItem) objLjMenuItem).select(false);
			} else if (objLjMenuItem instanceof JMenu) {
				FileActions.doUncheckPatternsMenuItems((JMenu) objLjMenuItem);
			}
		}
	}
}
 
开发者ID:jugglemaster,项目名称:JuggleMasterPro,代码行数:15,代码来源:FileActions.java

示例13: createMainMenuBars

import javax.swing.JMenu; //导入方法依赖的package包/类
public static JMenuBar createMainMenuBars(List<XML_Menu> menuLayers, List<XML_Menu> menuLayersLocal) {
	JMenuBar mainMenuBar = new JMenuBar();
	for (XML_Menu sub_menu : menuLayers) {
		if ( mapApp.start != null ) {
			mapApp.start.setText("Initializing " + sub_menu.name + " Menu...");
		}
		if ( sub_menu.proj.toLowerCase().indexOf(MapApp.CURRENT_PROJECTION.toLowerCase()) != -1 ) {
			JMenu subMenu = createMenu(sub_menu);
			if (subMenu.getItemCount() != 0)
				mainMenuBar.add(subMenu);
				subMenu.addMenuListener(mapApp.listener);
		}
	}
	// Add My Sessions Menu
	for (XML_Menu sub_menu2 : menuLayersLocal) {
		if ( mapApp.start != null ) {
			mapApp.start.setText("Initializing " + sub_menu2.name + " Menu...");
		}
		if ( sub_menu2.proj.toLowerCase().indexOf(MapApp.CURRENT_PROJECTION.toLowerCase()) != -1 ) {
			JMenu subMenu2 = createMenu(sub_menu2);
			if (subMenu2.getItemCount() != 0)
				mainMenuBar.add(subMenu2);
				subMenu2.addMenuListener(mapApp.listener);
		}
	}

	if ( mapApp != null && mapApp.start != null ) {
		mapApp.start.setText("Initializing GUI");
	}
	return mainMenuBar;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:32,代码来源:XML_Menu.java

示例14: fixMenu

import javax.swing.JMenu; //导入方法依赖的package包/类
private static void fixMenu(JMenu menu) {
    for (int i = menu.getItemCount(); i > 3; i--) {
        menu.remove(i - 1);
    }

    for (MysterFrame frame : windows) {
        new MysterMenuItemFactory(frame.getTitle(), new OtherWindowHandler(frame))
                .makeMenuItem(frame, menu);
    }
}
 
开发者ID:addertheblack,项目名称:myster,代码行数:11,代码来源:WindowManager.java

示例15: createMenu

import javax.swing.JMenu; //导入方法依赖的package包/类
public static JMenu createMenu(XML_Menu menuLayer) {
	JMenu menu = new JMenu(menuLayer.name);
	menuToMenuItem.put(menuLayer, menu);

	boolean isEnabled = false;

	for (XML_Menu sub_menu : menuLayer.child_layers) {
		if (sub_menu.proj != null) {
			//Don't do for imported sessions as we are now adding all sessions to the menu, and will
			//switch projection when loading.
			if ( !(menuLayer.parent != null && menuLayer.parent.name.equals("My Layer Sessions")) &&
					!menuLayer.name.equals("My Layer Sessions") &&
					!sub_menu.proj.toLowerCase().contains(MapApp.CURRENT_PROJECTION.toLowerCase())) {
				if ( sub_menu.separator_bar != null )
					menu.addSeparator();
				continue;
			}
		}
		if (sub_menu.os != null)
			if (!current_os.toLowerCase().contains(sub_menu.os.toLowerCase()))
				continue;

		if ( sub_menu.child_layers.size() > 0 ) {
			JMenu subMenu = createMenu(sub_menu);
			if (subMenu.getItemCount() != 0)
				menu.add(subMenu);

			isEnabled = isEnabled || subMenu.isEnabled();
		}
		else {
			JMenuItem mi = createMenuItem(sub_menu);

			isEnabled = isEnabled || mi.isEnabled();

			if ( sub_menu.separator_bar != null ) {
				if ( sub_menu.separator_bar.equals("above")) {
					menu.addSeparator();
					menu.add(mi);
				}
				else {
					menu.add(mi);
					menu.addSeparator();
				}
			}
			else {
				menu.add(mi);
			}
		}
	}

	if ("true".equalsIgnoreCase(menuLayer.isRemote) && MapApp.AT_SEA)
		menu.setEnabled(false);
	else
		menu.setEnabled(isEnabled);

	return menu;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:58,代码来源:XML_Menu.java


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