當前位置: 首頁>>代碼示例>>Java>>正文


Java MenuElement.getSubElements方法代碼示例

本文整理匯總了Java中javax.swing.MenuElement.getSubElements方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuElement.getSubElements方法的具體用法?Java MenuElement.getSubElements怎麽用?Java MenuElement.getSubElements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.MenuElement的用法示例。


在下文中一共展示了MenuElement.getSubElements方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: launch

import javax.swing.MenuElement; //導入方法依賴的package包/類
@Override
public MenuElement launch() {
    MenuElement element = getMenuElement();
    if (element != null) {
        MenuElement[] subElements = element.getSubElements();
        for (MenuElement subElement : subElements) {
            if (((Component) subElement).isShowing()
                    && ((Component) subElement).isEnabled()
                    && chooser.checkPathComponent(depth, subElement)) {
                process(subElement);
                return subElement;
            }
            if (stopped) {
                return null;
            }
        }
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:QueueJMenuDriver.java

示例2: attachActionListener

import javax.swing.MenuElement; //導入方法依賴的package包/類
/**
 * Recursively attach the given action listener to all items in the
 * given menu that have a non-<code>null</code> action command
 *  
 * @param menuElement The menu element
 * @param actionListener The action listener
 */
private static void attachActionListener(
    MenuElement menuElement, ActionListener actionListener)
{
    if (menuElement instanceof JMenuItem)
    {
        JMenuItem menuItem = (JMenuItem)menuElement;
        if (menuItem.getActionCommand() != null)
        {
            menuItem.addActionListener(actionListener);
        }
    }
    MenuElement[] subElements = menuElement.getSubElements();
    for (MenuElement subElement : subElements)
    {
        attachActionListener(subElement, actionListener);
    }
}
 
開發者ID:javagl,項目名稱:JglTF,代碼行數:25,代碼來源:GltfBrowserApplication.java

示例3: actionPerformed

import javax.swing.MenuElement; //導入方法依賴的package包/類
public void actionPerformed(final ActionEvent e) {
    final MenuElement[] path = getSelectedPath();
    if (path.length > 3 || path[0] instanceof JPopupMenu) {
        final MenuElement lastElement = path[path.length - 1];
        final MenuElement[] subElements = lastElement.getSubElements();
        if (!Utilities.isEmptyArray(subElements)) {
            MenuElement[] newPath;
            final MenuElement newSelectedItem = subElements[0];
            final MenuElement newSelectedChild = Utilities.getFirstSelectableItem(newSelectedItem.getSubElements());
            if (newSelectedItem instanceof JPopupMenu && newSelectedChild != null) {
                newPath = derivePath(path, path.length + 2, path.length);
                newPath[path.length + 1] = newSelectedChild;
            } else {
                newPath = derivePath(path, path.length + 1, path.length);
            }
            newPath[path.length] = newSelectedItem;
            setSelectedPath(newPath);
            return;
        }
    }
    selectNextTopLevelMenu(path);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:23,代碼來源:MenuKeyBindingProcessor.java

示例4: findScraperAction

import javax.swing.MenuElement; //導入方法依賴的package包/類
private Action findScraperAction(MenuElement scrapeMenu, String scraperKey) {

		if (scrapeMenu instanceof JMenuItem) {
			JMenuItem menuItem = (JMenuItem) scrapeMenu;
			Action action = menuItem.getAction();
			if (action != null) {
				String key = (String) action.getValue(ScrapeAmalgamatedAction.SCRAPE_KEY);
				if (key != null && key.equals(scraperKey)) {
					return action;
				}
			}
		}

		for (MenuElement childMenu : scrapeMenu.getSubElements()) {
			Action childAction = findScraperAction(childMenu, scraperKey);
			if (childAction != null) {
				return childAction;
			}
		}

		return null;
	}
 
開發者ID:DoctorD1501,項目名稱:JAVMovieScraper,代碼行數:23,代碼來源:GUIMainButtonPanel.java

示例5: installListener

import javax.swing.MenuElement; //導入方法依賴的package包/類
public static <T> void installListener(MenuElement menu, PopupSelectionListener<T> listener)
{
	for(MenuElement element : menu.getSubElements())
	{
		if(element instanceof JMenuItem)
		{
			final JMenuItem item = (JMenuItem) element;
			
			for(ActionListener l : item.getActionListeners())
				item.removeActionListener(l);
			
			item.addActionListener((event) -> {
				T userData = getUserData(item);
				if(userData != null)
					listener.itemSelected(userData);
			});
		}
		
		installListener(element, listener);
	}
}
 
開發者ID:justin-espedal,項目名稱:polydes,代碼行數:22,代碼來源:PopupUtil.java

示例6: getSelectedElement

import javax.swing.MenuElement; //導入方法依賴的package包/類
private static MenuElement getSelectedElement(MenuElement bar) {
    MenuElement[] subElements = bar.getSubElements();
    for (MenuElement subElement : subElements) {
        if (subElement instanceof JMenu
                && ((JMenu) subElement).isSelected()) {
            return subElement;
        } else if (subElement instanceof JMenuItem
                && ((JMenuItem) subElement).isSelected()) {
            return subElement;
        }
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:AppleMenuDriver.java

示例7: componentsInMenu

import javax.swing.MenuElement; //導入方法依賴的package包/類
private List<Component> componentsInMenu(MenuElement menuElement) {
    List<Component> list = new ArrayList<Component>();
    for (MenuElement element : menuElement.getSubElements()) {
        list.add(element.getComponent());
    }
    return list;
}
 
開發者ID:google-code-export,項目名稱:windowlicker,代碼行數:8,代碼來源:RecursiveComponentFinder.java

示例8: isMenuSubElement

import javax.swing.MenuElement; //導入方法依賴的package包/類
/**
 * Returns if <code>element</code> is the subElement of <code>container</code>.
 *
 * @param container menu to look for sub element at
 * @param element element to check
 * @return <code>true</code> if <code>element</code> is the subElement of <code>container</code>,
 * <code>false</code> otherwise
 */
public static boolean isMenuSubElement(final MenuElement container, final MenuElement element) {
    final MenuElement[] subElements = container.getSubElements();
    for (int i = 0; i < subElements.length; i++) {
        if (subElements[i] == element) {
            return true;
        }
    }
    return false;
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:18,代碼來源:Utilities.java

示例9: setActionsMenu

import javax.swing.MenuElement; //導入方法依賴的package包/類
private static void setActionsMenu(JDialog dialog, MenuElement menu) {
        MenuElement[] subItems = menu.getSubElements();
        InputMap inputMap = dialog.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
        for (MenuElement menuElement : subItems) {
            if (menuElement instanceof JMenuItem) {
                final JMenuItem menuItem = (JMenuItem) menuElement;
                if (menuItem.getAccelerator() != null) {
                    String key = "hackAction" + counter++;
                    inputMap.put(menuItem.getAccelerator(), key);

                    if (menuItem.getAction() == null) {
                        dialog.getRootPane().getActionMap().put(key,
                                new AbstractAction() {
                            @Override
                            public void actionPerformed(ActionEvent e) {
                                menuItem.doClick();
                            }
                        });
                    } else {
                        dialog.getRootPane().getActionMap().put(key,
                                menuItem.getAction());
                    }

//                     System.out.println(key + " : "
//                     + menuItem.getText()+ " : "
//                     + menuItem.getActionCommand() + " : "
//                     + menuItem.getAccelerator() + " : "
//                     + menuItem.getAction());
                }
            }
            // the original code had an else condition here, which is wrong.
            // JMenu is a subclass of JMenuItem, which prevents sub-menus from being traversed.
            if (menuElement.getSubElements().length > 0) {
                setActionsMenu(dialog, menuElement);
            }
        }
    }
 
開發者ID:OSUCartography,項目名稱:PyramidShader,代碼行數:38,代碼來源:MenuKeysDispatcher.java

示例10: createDisabledIconsForMenuEntries

import javax.swing.MenuElement; //導入方法依賴的package包/類
/**
 * Creates icons for the disabled state for all JMenuItems with FontBasedIcons in the given menuElement.
 * This is necessary as Swing is not able to generate default disabled icons for font based icons.
 *
 * @param menuElement the menuElement for which disabled icons should be generated
 */
public void createDisabledIconsForMenuEntries(MenuElement menuElement) {
    for (MenuElement subElement : menuElement.getSubElements()) {
        if ((subElement instanceof JMenu) || (subElement instanceof JPopupMenu)) {
            createDisabledIconsForMenuEntries(subElement);
        } else if (subElement instanceof JMenuItem) {
            JMenuItem item = (JMenuItem) subElement;
            if (item.getIcon() instanceof IconTheme.FontBasedIcon) {
                item.setDisabledIcon(((IconTheme.FontBasedIcon) item.getIcon()).createDisabledIcon());
            }
        }
    }
}
 
開發者ID:JabRef,項目名稱:jabref,代碼行數:19,代碼來源:JabRefFrame.java

示例11: appendMenuSubElements

import javax.swing.MenuElement; //導入方法依賴的package包/類
private static void appendMenuSubElements(MenuElement element, StringBuilder builder, String indent) {
    for (MenuElement subItem : element.getSubElements()) {
        appendMenuItem((Component)subItem, builder, indent);
    }
}
 
開發者ID:ib-controller,項目名稱:ib-controller,代碼行數:6,代碼來源:SwingUtils.java


注:本文中的javax.swing.MenuElement.getSubElements方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。