本文整理汇总了Java中javax.swing.JMenu.getItem方法的典型用法代码示例。如果您正苦于以下问题:Java JMenu.getItem方法的具体用法?Java JMenu.getItem怎么用?Java JMenu.getItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JMenu
的用法示例。
在下文中一共展示了JMenu.getItem方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
示例2: 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);
}
}
}
}
示例3: 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);
}
}
}
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
}
}
}