Java Code Examples for javax.swing.MenuSelectionManager

The following examples show how to use javax.swing.MenuSelectionManager. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: marathonv5   Source File: JPopupMenuTest.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeMethod
public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame(JPopupMenuTest.class.getSimpleName());
            frame.setName("frame-" + JPopupMenuTest.class.getSimpleName());
            PopupMenuDemo demo = new PopupMenuDemo();
            frame.setJMenuBar(demo.createMenuBar());
            frame.setContentPane(demo.createContentPane());

            // Create and set up the popup menu.
            demo.createPopupMenu();

            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });
    MenuSelectionManager.defaultManager().clearSelectedPath();
}
 
Example 2
public static void main(String[] args) throws Exception {
    SwingUtilities.invokeAndWait(() -> {

        JPopupMenu popup = new JPopupMenu("Popup Menu");
        JMenu menu = new JMenu("Menu");
        menu.add(new JMenuItem("Menu Item"));
        popup.add(menu);
        menu.doClick();
        MenuElement[] elems = MenuSelectionManager
                .defaultManager().getSelectedPath();

        if (elems == null || elems.length == 0) {
            throw new RuntimeException("Empty Selection");
        }

        if (elems[0] != popup || elems[1] != menu) {
            throw new RuntimeException("Necessary menus are not selected!");
        }
    });
}
 
Example 3
Source Project: netbeans   Source File: StayOpenPopupMenu.java    License: Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 4
Source Project: marathonv5   Source File: RMenuItemTest.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeMethod
public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            MenuSelectionManager.defaultManager().clearSelectedPath();
            frame = new JFrame(RMenuItemTest.class.getSimpleName());
            frame.setName("frame-" + RMenuItemTest.class.getSimpleName());
            MenuDemo demo = new MenuDemo();
            frame.setJMenuBar(demo.createMenuBar());
            frame.setContentPane(demo.createContentPane());
            frame.pack();
            frame.setVisible(true);
        }
    });
    menus = ComponentUtils.findComponents(JMenu.class, frame);
}
 
Example 5
Source Project: seaglass   Source File: SeaGlassCheckBoxMenuItemUI.java    License: Apache License 2.0 6 votes vote down vote up
public void processMouseEvent(JMenuItem item, MouseEvent e, MenuElement path[], MenuSelectionManager manager) {
    Point p = e.getPoint();
    if (p.x >= 0 && p.x < item.getWidth() && p.y >= 0 && p.y < item.getHeight()) {
        if (e.getID() == MouseEvent.MOUSE_RELEASED) {
            manager.clearSelectedPath();
            item.doClick(0);
        } else {
            manager.setSelectedPath(path);
        }
    } else if (item.getModel().isArmed()) {
        int c = path.length - 1;
        MenuElement newPath[] = new MenuElement[c];
        for (int i = 0; i < c; i++) {
            newPath[i] = path[i];
        }
        manager.setSelectedPath(newPath);
    }
}
 
Example 6
Source Project: marathonv5   Source File: JMenuItemJavaElement2Test.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeMethod
public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame(JMenuItemJavaElement2Test.class.getSimpleName());
            frame.setName("frame-" + JMenuItemJavaElement2Test.class.getSimpleName());
            PopupMenuDemoX demo = new PopupMenuDemoX();
            frame.setJMenuBar(demo.createMenuBar());
            frame.setContentPane(demo.createContentPane());

            // Create and set up the popup menu.
            demo.createPopupMenu();

            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });
    MenuSelectionManager.defaultManager().clearSelectedPath();
    JavaElementFactory.add(JMenuItem.class, JMenuItemJavaElement.class);
}
 
Example 7
Source Project: constellation   Source File: RecentFileAction.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Workaround for JDK bug 6663119, it ensures that first item in submenu is
 * correctly selected during keyboard navigation.
 */
private void ensureSelected() {
    if (menu.getMenuComponentCount() <= 0) {
        return;
    }

    Component first = menu.getMenuComponent(0);
    if (!(first instanceof JMenuItem)) {
        return;
    }

    Point loc = MouseInfo.getPointerInfo().getLocation();
    SwingUtilities.convertPointFromScreen(loc, menu);
    MenuElement[] selPath
            = MenuSelectionManager.defaultManager().getSelectedPath();

    // apply workaround only when mouse is not hovering over menu
    // (which signalizes mouse driven menu traversing) and only
    // when selected menu path contains expected value - submenu itself
    if (!menu.contains(loc) && selPath.length > 0
            && menu.getPopupMenu() == selPath[selPath.length - 1]) {
        // select first item in submenu through MenuSelectionManager
        MenuElement[] newPath = new MenuElement[selPath.length + 1];
        System.arraycopy(selPath, 0, newPath, 0, selPath.length);
        JMenuItem firstItem = (JMenuItem) first;
        newPath[selPath.length] = firstItem;
        MenuSelectionManager.defaultManager().setSelectedPath(newPath);
    }
}
 
Example 8
/**
 * Maps
 * {@code JMenuBar.processKeyEvent(KeyEvent, MenuElement[], MenuSelectionManager)}
 * through queue
 */
public void processKeyEvent(final KeyEvent keyEvent, final MenuElement[] menuElement, final MenuSelectionManager menuSelectionManager) {
    runMapping(new MapVoidAction("processKeyEvent") {
        @Override
        public void map() {
            ((JMenuBar) getSource()).processKeyEvent(keyEvent, menuElement, menuSelectionManager);
        }
    });
}
 
Example 9
Source Project: hottub   Source File: WindowsRootPaneUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 10
Source Project: jdk8u-jdk   Source File: WindowsRootPaneUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    }
}
 
Example 11
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;
}
 
Example 12
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();
        }
    }
}
 
Example 13
Source Project: netbeans   Source File: AbstractQuickSearchComboBar.java    License: Apache License 2.0 5 votes vote down vote up
public AllMenuItem(Set<Category> evalCats) {
    this.evalCats = evalCats;
    this.totalCount = ProviderModel.getInstance()
            .getCategories().size();
    getModel().addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            if (isShowing() && model.isArmed()) {
                selectedPath = MenuSelectionManager.defaultManager()
                        .getSelectedPath();
            }
        }
    });
    addActionListener(this);
}
 
Example 14
Source Project: jdk8u-jdk   Source File: WindowsRootPaneUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 15
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();
        }
    }
}
 
Example 16
Source Project: hottub   Source File: WindowsRootPaneUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
        }
    }
}
 
Example 17
Source Project: jdk8u60   Source File: WindowsRootPaneUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 18
Source Project: JDKSourceCode1.8   Source File: WindowsRootPaneUI.java    License: MIT License 5 votes vote down vote up
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();
        }
    }
}
 
Example 19
/**
 * Sets the number of items in the scrolling portion of the menu.
 *
 * @param scrollCount the number of items to display at a time
 * @throws IllegalArgumentException if scrollCount is 0 or negative
 */
public void setScrollCount(int scrollCount) {
    if (scrollCount <= 0) {
        throw new IllegalArgumentException("scrollCount must be greater than 0");
    }
    this.scrollCount = scrollCount;
    MenuSelectionManager.defaultManager().clearSelectedPath();
}
 
Example 20
Source Project: openjdk-8   Source File: WindowsRootPaneUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 21
Source Project: jdk8u-jdk   Source File: WindowsRootPaneUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 22
public void mouseReleased(MouseEvent e) {
    MenuSelectionManager.defaultManager().processMouseEvent(e);
}
 
Example 23
public void mouseReleased(MouseEvent e) {
    MenuSelectionManager.defaultManager().processMouseEvent(e);
}
 
Example 24
public void mouseMoved(MouseEvent e) {
    MenuSelectionManager.defaultManager().processMouseEvent(e);
}
 
Example 25
Source Project: jdk8u-jdk   Source File: WindowsRootPaneUI.java    License: GNU General Public License v2.0 4 votes vote down vote up
void altReleased(KeyEvent ev) {
    if (menuCanceledOnPress) {
        WindowsLookAndFeel.setMnemonicHidden(true);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        return;
    }

    MenuSelectionManager msm =
        MenuSelectionManager.defaultManager();
    if (msm.getSelectedPath().length == 0) {
        // if no menu is active, we try activating the menubar

        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;

        // It might happen that the altRelease event is processed
        // with a reasonable delay since it has been generated.
        // Here we check the last deactivation time of the containing
        // window. If this time appears to be greater than the altRelease
        // event time the event is skipped to avoid unexpected menu
        // activation. See 7121442.
        // Also we must ensure that original source of key event belongs
        // to the same window object as winAncestor. See 8001633.
        boolean skip = false;
        Toolkit tk = Toolkit.getDefaultToolkit();
        if (tk instanceof SunToolkit) {
            Component originalSource = AWTAccessor.getKeyEventAccessor()
                    .getOriginalSource(ev);
            skip = SunToolkit.getContainingWindow(originalSource) != winAncestor ||
                    ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor);
        }

        if (menu != null && !skip) {
            MenuElement[] path = new MenuElement[2];
            path[0] = mbar;
            path[1] = menu;
            msm.setSelectedPath(path);
        } else if(!WindowsLookAndFeel.isMnemonicHidden()) {
            WindowsLookAndFeel.setMnemonicHidden(true);
            WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        }
    } else {
        if((msm.getSelectedPath())[0] instanceof ComboPopup) {
            WindowsLookAndFeel.setMnemonicHidden(true);
            WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        }
    }

}
 
Example 26
public void mouseDragged(MouseEvent e) {
    MenuSelectionManager.defaultManager().processMouseEvent(e);
}
 
Example 27
public void mouseEntered(MouseEvent e) {
    MenuSelectionManager.defaultManager().processMouseEvent(e);
}
 
Example 28
public void mousePressed(MouseEvent e) {
    MenuSelectionManager.defaultManager().processMouseEvent(e);
}
 
Example 29
Source Project: FlatLaf   Source File: MnemonicHandler.java    License: Apache License 2.0 4 votes vote down vote up
void uninstall() {
	KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventPostProcessor( this );
	MenuSelectionManager.defaultManager().removeChangeListener( this );
}
 
Example 30
public void mouseMoved(MouseEvent e) {
    MenuSelectionManager.defaultManager().processMouseEvent(e);
}