本文整理匯總了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;
}