本文整理汇总了Java中javax.swing.JMenuBar.getSubElements方法的典型用法代码示例。如果您正苦于以下问题:Java JMenuBar.getSubElements方法的具体用法?Java JMenuBar.getSubElements怎么用?Java JMenuBar.getSubElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JMenuBar
的用法示例。
在下文中一共展示了JMenuBar.getSubElements方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitMenuBar
import javax.swing.JMenuBar; //导入方法依赖的package包/类
/** Open all menus in menubar
* @param menu to be visited */
public static void visitMenuBar(JMenuBar menu) {
MenuElement[] elements = menu.getSubElements();
JMenuBarOperator op = new JMenuBarOperator(menu);
for (int k = 0; k < elements.length; k++) {
if (elements[k] instanceof JMenuItem) {
op.pushMenu(((JMenuItem) elements[k]).getText(), "/", true, true);
try {
op.wait(200);
} catch (Exception e) {
}
}
}
}
示例2: getMenuBarArrayList
import javax.swing.JMenuBar; //导入方法依赖的package包/类
/** Get MenuBar and tranfer it to ArrayList.
* @param menu menu to be tranfered
* @return tranfered menubar */
private static List<NbMenu> getMenuBarArrayList(JMenuBar menu) {
visitMenuBar(menu);
MenuElement [] elements = menu.getSubElements();
List<NbMenu> list = new ArrayList<NbMenu>();
for(int k=0; k < elements.length; k++) {
// if(elements[k] instanceof JMenuItem) {
// list.add(new NbMenu((JMenuItem)elements[k], null));
JMenuBarOperator menuOp = new JMenuBarOperator(menu);
JMenu item = menuOp.getMenu(k);
list.add(new NbMenu(item, getMenuArrayList(item)));
// }
/*if(elements[k] instanceof JMenuBar) {
JMenuBarOperator menuOp = new JMenuBarOperator(menu);
list.add(getMenuArrayList(menuOp.getMenu(0)));
}
*/
}
return list;
}
示例3: getMenuBarArrayList
import javax.swing.JMenuBar; //导入方法依赖的package包/类
/** Get MenuBar and tranfer it to ArrayList.
* @param menu menu to be tranfered
* @return tranfered menubar - !separator is ignored
*/
public static ArrayList<NbMenuItem> getMenuBarArrayList(JMenuBar menu) {
// System.out.println("getMenuBarArrayList " + menu.getName());
visitMenuBar(menu);
MenuElement[] elements = menu.getSubElements();
ArrayList<NbMenuItem> list = new ArrayList<NbMenuItem>();
for (int k = 0; k < elements.length; k++) {
if (elements[k] instanceof JPopupMenu.Separator) {
NbMenuItem separator = new NbMenuItem();
separator.setSeparator(true);
list.add(separator);
} else {
if (elements[k] instanceof JMenuItem) {
NbMenuItem item = new NbMenuItem((JMenuItem) elements[k]);
JMenuBarOperator menuOp = new JMenuBarOperator(menu);
item.setSubmenu(getMenuArrayList(menuOp.getMenu(k)));
list.add(item);
}
}
}
return list;
}
示例4: visitMenuBar
import javax.swing.JMenuBar; //导入方法依赖的package包/类
/** Open all menus in menubar
* @param menu to be visited */
private static void visitMenuBar(JMenuBar menu) {
JMenuBarOperator op = new JMenuBarOperator(menu);
for (MenuElement element : menu.getSubElements()) {
if (element instanceof JMenuItem) {
op.pushMenu(op.parseString(((JMenuItem) element).getText(), "/"), new DefaultStringComparator(true, true));
try {
op.wait(200);
}catch(Exception e) {}
}
}
}
示例5: getSelectedElement
import javax.swing.JMenuBar; //导入方法依赖的package包/类
public static Object getSelectedElement(JMenuBar bar) {
MenuElement[] subElements = bar.getSubElements();
for (MenuElement subElement : subElements) {
if (subElement instanceof JMenu
&& ((JMenu) subElement).isPopupMenuVisible()) {
return subElement;
}
}
return null;
}
示例6: isMenuBarSelected
import javax.swing.JMenuBar; //导入方法依赖的package包/类
private boolean isMenuBarSelected(JMenuBar bar) {
MenuElement[] subElements = bar.getSubElements();
for (MenuElement subElement : subElements) {
if (subElement instanceof JMenu
&& ((JMenu) subElement).isPopupMenuVisible()) {
return true;
}
}
return false;
}