本文整理汇总了Java中javax.swing.JMenu.getMenuComponentCount方法的典型用法代码示例。如果您正苦于以下问题:Java JMenu.getMenuComponentCount方法的具体用法?Java JMenu.getMenuComponentCount怎么用?Java JMenu.getMenuComponentCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JMenu
的用法示例。
在下文中一共展示了JMenu.getMenuComponentCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBindingsSubmenu
import javax.swing.JMenu; //导入方法依赖的package包/类
private void createBindingsSubmenu(JMenu menu) {
if (menu.getMenuComponentCount() > 0)
menu.removeAll();
Node[] nodes = getActivatedNodes();
if (nodes.length != 1)
return;
RADComponentCookie radCookie = nodes[0].getCookie(RADComponentCookie.class);
if (radCookie == null)
return;
BindingProperty[][] bindingProps = radCookie.getRADComponent().getBindingProperties();
BindingProperty[] props = bindingProps[(bindingProps[0].length==0) ? 1 : 0];
if (props.length > 0) {
for (BindingProperty prop : props) {
BindingMenuItem mi = new BindingMenuItem(prop);
mi.addActionListener(mi);
menu.add(mi);
}
} else {
JMenuItem item = new JMenuItem(NbBundle.getMessage(BindAction.class, "MSG_NoBinding")); // NOI18N
item.setEnabled(false);
menu.add(item);
}
}
示例2: setActionMenuBar
import javax.swing.JMenu; //导入方法依赖的package包/类
public void setActionMenuBar(String menuItem, Action action) {
for (int i = 0; i < mMenuBar.getMenuCount(); i++) {
JMenu menu = mMenuBar.getMenu(i);
for (int j = 0; j < menu.getMenuComponentCount(); j++) {
Component component = menu.getMenuComponent(j);
if (component instanceof JMenuItem) {
JMenuItem item = (JMenuItem) component;
String description = (String) item.getAction().getValue(Action.SHORT_DESCRIPTION);
if (description.equals(menuItem)) {
item.setAction(action);
item.setText(menuItem);
break;
}
}
}
}
}
示例3: enableAll
import javax.swing.JMenu; //导入方法依赖的package包/类
/**
* Convenience method that recursively enables every JMenu and JMenuItem
* inside "menu".
*
* @param menu - the menu to start the recursive search
*/
public static void enableAll(JMenu menu) {
for (int i = 0; i < menu.getMenuComponentCount(); i++) {
Component x = menu.getMenuComponent(i);
if (x instanceof JMenuItem)
((JMenuItem) x).setEnabled(true);
else if (x instanceof JMenu)
enableAll((JMenu) x);
}
}
示例4: setMenuText
import javax.swing.JMenu; //导入方法依赖的package包/类
public static void setMenuText(final JMenu menu) {
menu.setText(getString(menu.getText()));
for (int i = 0; i < menu.getMenuComponentCount(); i++) {
if (isParent(JMenuItem.class, menu.getMenuComponent(i).getClass())
&& !isParent(JMenu.class, menu.getMenuComponent(i)
.getClass()))
setMenuItemText((JMenuItem) menu.getMenuComponent(i));
else if (menu.getMenuComponent(i).getClass() == JMenu.class)
setMenuText((JMenu) menu.getMenuComponent(i));
}
}
示例5: setMnemonics
import javax.swing.JMenu; //导入方法依赖的package包/类
private static void setMnemonics(final JMenuItem item) {
if (item instanceof JMenu) {
final JMenu menu = (JMenu) item;
final int c = menu.getMenuComponentCount();
final ArrayList<JMenuItem> list = new ArrayList<JMenuItem>(c);
for (int i = 0; i < c; i++) {
final Component co = menu.getMenuComponent(i);
if (co instanceof JMenuItem)
list.add((JMenuItem) co);
}
if (list.size() > 0)
setMnemonics(list);
}
}
示例6: enableAll
import javax.swing.JMenu; //导入方法依赖的package包/类
/** Convenience method that recursively enables every JMenu and JMenuItem inside "menu".
* @param menu - the menu to start the recursive search
*/
public static void enableAll (JMenu menu) {
for(int i = 0; i < menu.getMenuComponentCount(); i++) {
Component x = menu.getMenuComponent(i);
if (x instanceof JMenuItem) ((JMenuItem)x).setEnabled(true); else if (x instanceof JMenu) enableAll((JMenu)x);
}
}