类javax.swing.MenuElement源码实例Demo

下面列出了怎么用javax.swing.MenuElement的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: visualvm   文件: StayOpenPopupMenu.java
public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager) {
    if (isReturnAction(e)) { // Handle SPACE and ENTER
        MenuElement[] p = manager.getSelectedPath();
        MenuElement m = p != null && p.length > 0 ? p[p.length - 1] : null;
        if (m instanceof StayOpen) {
            e.consume();
            if (e.getID() == KeyEvent.KEY_PRESSED)
                performAction((StayOpen)m, e.getModifiers());
            return;
        }
    } else for (Component component : getComponents()) { // Handle mnemonics and accelerators
        if (component instanceof StayOpen) {
            StayOpen item = (StayOpen)component;
            JMenuItem i = item.getItem();
            KeyStroke k = KeyStroke.getKeyStrokeForEvent(e);
            if (k.equals(mnemonic(i)) || k.equals(i.getAccelerator())) {
                e.consume();
                manager.setSelectedPath(new MenuElement[] { this, i });
                performAction(item, e.getModifiers());
                return;
            }
        }
    }
    
    super.processKeyEvent(e, path, manager);
}
 
源代码2 项目: amidst   文件: AmidstMenu.java
@CalledOnlyBy(AmidstThread.EDT)
private void runOnMenuItems(MenuElement menuElement, String[] textRepresentations, Consumer<JMenuItem> consumer) {
	MenuElement[] elements = menuElement.getSubElements();
	if(elements != null) {
		for(MenuElement element : elements) {
			if(element instanceof JMenuItem) {
				for(String s : textRepresentations) {
					if(((JMenuItem) element).getText().equals(s)) {
						consumer.accept((JMenuItem) element);
					}
				}
			}
			runOnMenuItems(element, textRepresentations, consumer);
		}
	}
}
 
源代码3 项目: JglTF   文件: GltfBrowserApplication.java
/**
 * 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);
    }
}
 
源代码4 项目: jpexs-decompiler   文件: MainFrameClassicMenu.java
@Override
public void setMenuEnabled(String path, boolean enabled) {
    path = mapping(path);
    if (path.equals("_") || path.startsWith("_/")) {
        return;
    }
    MenuElement menu = menuElements.get(path);
    if (menu == null) {
        throw new IllegalArgumentException("Menu " + path + " does not exist");
    }
    if (menu instanceof JMenuBar) {
        ((JMenuBar) menu).setEnabled(enabled);
    } else if (menu instanceof JMenu) {
        ((JMenu) menu).setEnabled(enabled);
    } else if (menu instanceof JMenuItem) {
        ((JMenuItem) menu).setEnabled(enabled);
    } else {
        throw new IllegalArgumentException(path + " is not a menu");
    }
}
 
源代码5 项目: ib-controller   文件: SwingUtils.java
private static void appendMenuItem(Component menuItem, StringBuilder builder, String indent) {
    if (menuItem instanceof JMenuBar) {
        appendMenuSubElements((MenuElement)menuItem, builder, indent);
    } else if (menuItem instanceof JPopupMenu) {
        appendMenuSubElements((MenuElement)menuItem, builder, indent);
    } else if (menuItem instanceof JMenuItem) {
        builder.append(NEWLINE);
        builder.append(indent);
        builder.append(((JMenuItem)menuItem).getText());
        builder.append(((JMenuItem)menuItem).isEnabled() ? "" : "[Disabled]");
        appendMenuSubElements((JMenuItem)menuItem, builder, "|   " + indent);
    } else if (menuItem instanceof JSeparator) {
        builder.append(NEWLINE);
        builder.append(indent);
        builder.append("--------");
    }
}
 
源代码6 项目: netbeans   文件: MenuChecker.java
/** 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) {
            }
        }
    }
}
 
源代码7 项目: jpexs-decompiler   文件: MainFrameClassicMenu.java
@Override
public void addSeparator(String parentPath) {
    parentPath = mapping(parentPath);
    if (parentPath.equals("_") || parentPath.startsWith("_/")) {
        return;
    }
    if (!menuElements.containsKey(parentPath)) {
        throw new IllegalArgumentException("Menu does not exist: " + parentPath);
    }
    MenuElement parent = menuElements.get(parentPath);
    if (parent instanceof JMenu) {
        ((JMenu) parent).addSeparator();
    } else {
        throw new IllegalArgumentException("Not a menu: " + parentPath);
    }
}
 
源代码8 项目: jdk8u-jdk   文件: WindowsRootPaneUI.java
public boolean postProcessKeyEvent(KeyEvent ev) {
    if(ev.isConsumed() && ev.getKeyCode() != KeyEvent.VK_ALT) {
        // mnemonic combination, it's consumed, but we need
        // set altKeyPressed to false, otherwise after selection
        // component by mnemonic combination a menu will be open
        altKeyPressed = false;
        return false;
    }
    if (ev.getKeyCode() == KeyEvent.VK_ALT) {
        root = SwingUtilities.getRootPane(ev.getComponent());
        winAncestor = (root == null ? null :
                SwingUtilities.getWindowAncestor(root));

        if (ev.getID() == KeyEvent.KEY_PRESSED) {
            if (!altKeyPressed) {
                altPressed(ev);
            }
            altKeyPressed = true;
            return true;
        } else if (ev.getID() == KeyEvent.KEY_RELEASED) {
            if (altKeyPressed) {
                altReleased(ev);
            } else {
                MenuSelectionManager msm =
                    MenuSelectionManager.defaultManager();
                MenuElement[] path = msm.getSelectedPath();
                if (path.length <= 0) {
                    WindowsLookAndFeel.setMnemonicHidden(true);
                    WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
                }
            }
            altKeyPressed = false;
        }
        root = null;
        winAncestor = null;
    } else {
        altKeyPressed = false;
    }
    return false;
}
 
void altPressed(KeyEvent ev) {
    MenuSelectionManager msm =
        MenuSelectionManager.defaultManager();
    MenuElement[] path = msm.getSelectedPath();
    if (path.length > 0 && ! (path[0] instanceof ComboPopup)) {
        msm.clearSelectedPath();
        menuCanceledOnPress = true;
        ev.consume();
    } else if(path.length > 0) { // We are in ComboBox
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        ev.consume();
    } else {
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        JMenuBar mbar = root != null ? root.getJMenuBar() : null;
        if(mbar == null && winAncestor instanceof JFrame) {
            mbar = ((JFrame)winAncestor).getJMenuBar();
        }
        JMenu menu = mbar != null ? mbar.getMenu(0) : null;
        if(menu != null) {
            ev.consume();
        }
    }
}
 
源代码10 项目: jdk1.8-source-analysis   文件: WindowsRootPaneUI.java
public boolean postProcessKeyEvent(KeyEvent ev) {
    if(ev.isConsumed() && ev.getKeyCode() != KeyEvent.VK_ALT) {
        // mnemonic combination, it's consumed, but we need
        // set altKeyPressed to false, otherwise after selection
        // component by mnemonic combination a menu will be open
        altKeyPressed = false;
        return false;
    }
    if (ev.getKeyCode() == KeyEvent.VK_ALT) {
        root = SwingUtilities.getRootPane(ev.getComponent());
        winAncestor = (root == null ? null :
                SwingUtilities.getWindowAncestor(root));

        if (ev.getID() == KeyEvent.KEY_PRESSED) {
            if (!altKeyPressed) {
                altPressed(ev);
            }
            altKeyPressed = true;
            return true;
        } else if (ev.getID() == KeyEvent.KEY_RELEASED) {
            if (altKeyPressed) {
                altReleased(ev);
            } else {
                MenuSelectionManager msm =
                    MenuSelectionManager.defaultManager();
                MenuElement[] path = msm.getSelectedPath();
                if (path.length <= 0) {
                    WindowsLookAndFeel.setMnemonicHidden(true);
                    WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
                }
            }
            altKeyPressed = false;
        }
        root = null;
        winAncestor = null;
    } else {
        altKeyPressed = false;
    }
    return false;
}
 
源代码11 项目: jpexs-decompiler   文件: MainFrameClassicMenu.java
@Override
public void finishMenu(String path) {
    path = mapping(path);
    if (path.equals("_") || path.startsWith("_/")) {
        return;
    }
    if (!menuElements.containsKey(path)) {
        throw new IllegalArgumentException("Invalid menu: " + path);
    }
    if (path.startsWith("/file/recent")) {
        return;
    }
    MenuElement me = menuElements.get(path);
    if (me instanceof JMenu) {
        JMenu jm = (JMenu) me;
        if (jm.getMenuComponentCount() == 1) {
            String parentPath = path.contains("/") ? path.substring(0, path.lastIndexOf('/')) : "";
            MenuElement parMe = menuElements.get(parentPath);
            JMenuItem mi = (JMenuItem) jm.getMenuComponent(0);
            jm.remove(mi);
            if (parMe instanceof JMenu) {
                JMenu parMenu = (JMenu) parMe;
                parMenu.remove(jm);
                parMenu.add(mi);
            } else if (parMe instanceof JMenuBar) {
                JMenuBar parMenuBar = (JMenuBar) parMe;
                parMenuBar.remove(jm);
                parMenuBar.add(mi);
            }
        }
    }
}
 
源代码12 项目: FlatLaf   文件: FlatMenuBarUI.java
@Override
public void actionPerformed( ActionEvent e ) {
	JMenuBar menuBar = (JMenuBar) e.getSource();
	JMenu menu = menuBar.getMenu( 0 );
	if( menu != null ) {
		MenuSelectionManager.defaultManager().setSelectedPath( SystemInfo.IS_WINDOWS
			? new MenuElement[] { menuBar, menu }
			: new MenuElement[] { menuBar, menu, menu.getPopupMenu() } );

		FlatLaf.showMnemonics( menuBar );
	}
}
 
源代码13 项目: dragonwell8_jdk   文件: WindowsRootPaneUI.java
public boolean postProcessKeyEvent(KeyEvent ev) {
    if(ev.isConsumed() && ev.getKeyCode() != KeyEvent.VK_ALT) {
        // mnemonic combination, it's consumed, but we need
        // set altKeyPressed to false, otherwise after selection
        // component by mnemonic combination a menu will be open
        altKeyPressed = false;
        return false;
    }
    if (ev.getKeyCode() == KeyEvent.VK_ALT) {
        root = SwingUtilities.getRootPane(ev.getComponent());
        winAncestor = (root == null ? null :
                SwingUtilities.getWindowAncestor(root));

        if (ev.getID() == KeyEvent.KEY_PRESSED) {
            if (!altKeyPressed) {
                altPressed(ev);
            }
            altKeyPressed = true;
            return true;
        } else if (ev.getID() == KeyEvent.KEY_RELEASED) {
            if (altKeyPressed) {
                altReleased(ev);
            } else {
                MenuSelectionManager msm =
                    MenuSelectionManager.defaultManager();
                MenuElement[] path = msm.getSelectedPath();
                if (path.length <= 0) {
                    WindowsLookAndFeel.setMnemonicHidden(true);
                    WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
                }
            }
            altKeyPressed = false;
        }
        root = null;
        winAncestor = null;
    } else {
        altKeyPressed = false;
    }
    return false;
}
 
源代码14 项目: TencentKona-8   文件: WindowsRootPaneUI.java
void altPressed(KeyEvent ev) {
    MenuSelectionManager msm =
        MenuSelectionManager.defaultManager();
    MenuElement[] path = msm.getSelectedPath();
    if (path.length > 0 && ! (path[0] instanceof ComboPopup)) {
        msm.clearSelectedPath();
        menuCanceledOnPress = true;
        ev.consume();
    } else if(path.length > 0) { // We are in ComboBox
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        ev.consume();
    } else {
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        JMenuBar mbar = root != null ? root.getJMenuBar() : null;
        if(mbar == null && winAncestor instanceof JFrame) {
            mbar = ((JFrame)winAncestor).getJMenuBar();
        }
        JMenu menu = mbar != null ? mbar.getMenu(0) : null;
        if(menu != null) {
            ev.consume();
        }
    }
}
 
源代码15 项目: jpexs-decompiler   文件: MainFrameClassicMenu.java
@Override
public boolean isMenuChecked(String path) {
    path = mapping(path);
    MenuElement menu = menuElements.get(path);
    if (menu == null) {
        throw new IllegalArgumentException("Menu " + path + " does not exist");
    }
    if (menu instanceof JCheckBoxMenuItem) {
        return ((JCheckBoxMenuItem) menu).isSelected();
    } else if (menu instanceof JRadioButtonMenuItem) {
        return ((JRadioButtonMenuItem) menu).isSelected();
    } else {
        throw new IllegalArgumentException(path + " is not selectable menu item");
    }
}
 
源代码16 项目: jdk8u-jdk   文件: WindowsRootPaneUI.java
public boolean postProcessKeyEvent(KeyEvent ev) {
    if(ev.isConsumed()) {
        // do not manage consumed event
        return false;
    }
    if (ev.getKeyCode() == KeyEvent.VK_ALT) {
        root = SwingUtilities.getRootPane(ev.getComponent());
        winAncestor = (root == null ? null :
                SwingUtilities.getWindowAncestor(root));

        if (ev.getID() == KeyEvent.KEY_PRESSED) {
            if (!altKeyPressed) {
                altPressed(ev);
            }
            altKeyPressed = true;
            return true;
        } else if (ev.getID() == KeyEvent.KEY_RELEASED) {
            if (altKeyPressed) {
                altReleased(ev);
            } else {
                MenuSelectionManager msm =
                    MenuSelectionManager.defaultManager();
                MenuElement[] path = msm.getSelectedPath();
                if (path.length <= 0) {
                    WindowsLookAndFeel.setMnemonicHidden(true);
                    WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
                }
            }
            altKeyPressed = false;
        }
        root = null;
        winAncestor = null;
    } else {
        altKeyPressed = false;
    }
    return false;
}
 
源代码17 项目: openjdk-8-source   文件: WindowsRootPaneUI.java
void altPressed(KeyEvent ev) {
    MenuSelectionManager msm =
        MenuSelectionManager.defaultManager();
    MenuElement[] path = msm.getSelectedPath();
    if (path.length > 0 && ! (path[0] instanceof ComboPopup)) {
        msm.clearSelectedPath();
        menuCanceledOnPress = true;
        ev.consume();
    } else if(path.length > 0) { // We are in ComboBox
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        ev.consume();
    } else {
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        JMenuBar mbar = root != null ? root.getJMenuBar() : null;
        if(mbar == null && winAncestor instanceof JFrame) {
            mbar = ((JFrame)winAncestor).getJMenuBar();
        }
        JMenu menu = mbar != null ? mbar.getMenu(0) : null;
        if(menu != null) {
            ev.consume();
        }
    }
}
 
源代码18 项目: JDKSourceCode1.8   文件: WindowsRootPaneUI.java
void altPressed(KeyEvent ev) {
    MenuSelectionManager msm =
        MenuSelectionManager.defaultManager();
    MenuElement[] path = msm.getSelectedPath();
    if (path.length > 0 && ! (path[0] instanceof ComboPopup)) {
        msm.clearSelectedPath();
        menuCanceledOnPress = true;
        ev.consume();
    } else if(path.length > 0) { // We are in ComboBox
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        ev.consume();
    } else {
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        JMenuBar mbar = root != null ? root.getJMenuBar() : null;
        if(mbar == null && winAncestor instanceof JFrame) {
            mbar = ((JFrame)winAncestor).getJMenuBar();
        }
        JMenu menu = mbar != null ? mbar.getMenu(0) : null;
        if(menu != null) {
            ev.consume();
        }
    }
}
 
源代码19 项目: PyramidShader   文件: MenuKeysDispatcher.java
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);
            }
        }
    }
 
源代码20 项目: openjdk-8   文件: WindowsRootPaneUI.java
public boolean postProcessKeyEvent(KeyEvent ev) {
    if(ev.isConsumed()) {
        // do not manage consumed event
        return false;
    }
    if (ev.getKeyCode() == KeyEvent.VK_ALT) {
        root = SwingUtilities.getRootPane(ev.getComponent());
        winAncestor = (root == null ? null :
                SwingUtilities.getWindowAncestor(root));

        if (ev.getID() == KeyEvent.KEY_PRESSED) {
            if (!altKeyPressed) {
                altPressed(ev);
            }
            altKeyPressed = true;
            return true;
        } else if (ev.getID() == KeyEvent.KEY_RELEASED) {
            if (altKeyPressed) {
                altReleased(ev);
            } else {
                MenuSelectionManager msm =
                    MenuSelectionManager.defaultManager();
                MenuElement[] path = msm.getSelectedPath();
                if (path.length <= 0) {
                    WindowsLookAndFeel.setMnemonicHidden(true);
                    WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
                }
            }
            altKeyPressed = false;
        }
        root = null;
        winAncestor = null;
    } else {
        altKeyPressed = false;
    }
    return false;
}
 
源代码21 项目: jpexs-decompiler   文件: MainFrameClassicMenu.java
@Override
public void addMenuItem(String path, String title, String icon, ActionListener action, int priority, final ActionListener subLoader, boolean isLeaf, HotKey key, boolean isOptional) {
    path = mapping(path);

    menuHotkeys.put(path, key);
    menuActions.put(path, action);

    if (!isLeaf) {
        //action is ignored
        addMenu(path, title, icon, subLoader);
        return;
    }
    if (path.startsWith("_/")) {
        return;
    }
    String parentPath = "";
    if (path.contains("/")) {
        parentPath = path.substring(0, path.lastIndexOf('/'));
    }
    MenuElement parentMenu = menuElements.get(parentPath);
    if (parentMenu == null) {
        throw new IllegalArgumentException("Parent menu " + path + " does not exist");
    }
    JMenuItem menuItem = new JMenuItem(title);
    if (icon != null) {
        menuItem.setIcon(View.getIcon(icon, 16));
    }
    if (action != null) {
        menuItem.addActionListener(action);
    }
    if (key != null) {
        menuItem.setAccelerator(KeyStroke.getKeyStroke(key.key, key.getModifier()));
    }
    if (parentMenu instanceof JMenu) {
        ((JMenu) parentMenu).add(menuItem);
    } else {
        throw new IllegalArgumentException("Parent path " + path + " is not a menu");
    }
    menuElements.put(path, menuItem);
}
 
源代码22 项目: openjdk-jdk8u   文件: WindowsRootPaneUI.java
void altPressed(KeyEvent ev) {
    MenuSelectionManager msm =
        MenuSelectionManager.defaultManager();
    MenuElement[] path = msm.getSelectedPath();
    if (path.length > 0 && ! (path[0] instanceof ComboPopup)) {
        msm.clearSelectedPath();
        menuCanceledOnPress = true;
        ev.consume();
    } else if(path.length > 0) { // We are in ComboBox
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        ev.consume();
    } else {
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        JMenuBar mbar = root != null ? root.getJMenuBar() : null;
        if(mbar == null && winAncestor instanceof JFrame) {
            mbar = ((JFrame)winAncestor).getJMenuBar();
        }
        JMenu menu = mbar != null ? mbar.getMenu(0) : null;
        if(menu != null) {
            ev.consume();
        }
    }
}
 
源代码23 项目: openjdk-jdk8u   文件: WindowsRootPaneUI.java
public boolean postProcessKeyEvent(KeyEvent ev) {
    if(ev.isConsumed() && ev.getKeyCode() != KeyEvent.VK_ALT) {
        // mnemonic combination, it's consumed, but we need
        // set altKeyPressed to false, otherwise after selection
        // component by mnemonic combination a menu will be open
        altKeyPressed = false;
        return false;
    }
    if (ev.getKeyCode() == KeyEvent.VK_ALT) {
        root = SwingUtilities.getRootPane(ev.getComponent());
        winAncestor = (root == null ? null :
                SwingUtilities.getWindowAncestor(root));

        if (ev.getID() == KeyEvent.KEY_PRESSED) {
            if (!altKeyPressed) {
                altPressed(ev);
            }
            altKeyPressed = true;
            return true;
        } else if (ev.getID() == KeyEvent.KEY_RELEASED) {
            if (altKeyPressed) {
                altReleased(ev);
            } else {
                MenuSelectionManager msm =
                    MenuSelectionManager.defaultManager();
                MenuElement[] path = msm.getSelectedPath();
                if (path.length <= 0) {
                    WindowsLookAndFeel.setMnemonicHidden(true);
                    WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
                }
            }
            altKeyPressed = false;
        }
        root = null;
        winAncestor = null;
    } else {
        altKeyPressed = false;
    }
    return false;
}
 
源代码24 项目: openjdk-jdk9   文件: JPopupMenuOperator.java
/**
 * Maps {@code JPopupMenu.getSubElements()} through queue
 */
public MenuElement[] getSubElements() {
    return ((MenuElement[]) runMapping(new MapAction<Object>("getSubElements") {
        @Override
        public Object map() {
            return ((JPopupMenu) getSource()).getSubElements();
        }
    }));
}
 
源代码25 项目: openjdk-jdk9   文件: JPopupMenuOperator.java
/**
 * Maps
 * {@code JPopupMenu.processMouseEvent(MouseEvent, MenuElement[], MenuSelectionManager)}
 * through queue
 */
public void processMouseEvent(final MouseEvent mouseEvent, final MenuElement[] menuElement, final MenuSelectionManager menuSelectionManager) {
    runMapping(new MapVoidAction("processMouseEvent") {
        @Override
        public void map() {
            ((JPopupMenu) getSource()).processMouseEvent(mouseEvent, menuElement, menuSelectionManager);
        }
    });
}
 
源代码26 项目: netbeans   文件: MenuChecker.java
/** 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) {}
        }
    }
}
 
源代码27 项目: openjdk-jdk9   文件: JMenuItemOperator.java
/**
 * Maps {@code JMenuItem.getSubElements()} through queue
 */
public MenuElement[] getSubElements() {
    return ((MenuElement[]) runMapping(new MapAction<Object>("getSubElements") {
        @Override
        public Object map() {
            return ((JMenuItem) getSource()).getSubElements();
        }
    }));
}
 
源代码28 项目: netbeans   文件: AutoHidingMenuBar.java
private boolean isMenuItemSelected() {
    MenuElement[] selectedPath = MenuSelectionManager.defaultManager().getSelectedPath();
    return selectedPath != null && selectedPath.length > 0 &&
            /* Make sure the selection is in the main menu bar, not just a context menu
            somewhere. */
            selectedPath[0] == menuBar;
}
 
源代码29 项目: openjdk-jdk9   文件: JMenuBarOperator.java
/**
 * Maps {@code JMenuBar.getSubElements()} through queue
 */
public MenuElement[] getSubElements() {
    return ((MenuElement[]) runMapping(new MapAction<Object>("getSubElements") {
        @Override
        public Object map() {
            return ((JMenuBar) getSource()).getSubElements();
        }
    }));
}
 
源代码30 项目: jpexs-decompiler   文件: MainFrameClassicMenu.java
@Override
public void setMenuChecked(String path, boolean checked) {
    path = mapping(path);
    MenuElement menu = menuElements.get(path);
    if (menu == null) {
        throw new IllegalArgumentException("Menu " + path + " does not exist");
    }
    if (menu instanceof JCheckBoxMenuItem) {
        ((JCheckBoxMenuItem) menu).setSelected(checked);
    } else if (menu instanceof JRadioButtonMenuItem) {
        ((JRadioButtonMenuItem) menu).setSelected(checked);
    } else {
        throw new IllegalArgumentException(path + " is not selectable menu item");
    }
}
 
 类所在包
 类方法
 同包方法