Package javax.swing

Examples of javax.swing.MenuSelectionManager


      this.wrappedAction = wrappedAction;
    }

    public void actionPerformed(ActionEvent e) {

      MenuSelectionManager msm = MenuSelectionManager.defaultManager();
      MenuElement[] path = msm.getSelectedPath();
      int len = path.length;

      if (len > 2 && path[len - 3] instanceof ScrollableMenu && path[len - 2] instanceof JPopupMenu) {

        ScrollableMenu menu = (ScrollableMenu) path[len - 3];
View Full Code Here


        return result;
    }

    protected void doClick(final MenuSelectionManager msm) {
        MenuSelectionManager manager = (msm != null) ? msm : MenuSelectionManager.defaultManager();
        manager.clearSelectedPath();
        final BasicLookAndFeel lookAndFeel = (BasicLookAndFeel)UIManager.getLookAndFeel();
        lookAndFeel.fireSoundAction(menuItem, getPropertyPrefix() + ".commandSound");
        menuItem.doClick(0);
    }
View Full Code Here


public class BasicMenuItemUI extends MenuItemUI {
    protected class MouseInputHandler implements MouseInputListener {
        public void mouseEntered(final MouseEvent e) {
            final MenuSelectionManager manager = MenuSelectionManager.defaultManager();
            if (openMenuTimer != null) {
                openMenuTimer.stop();
            }
            manager.setSelectedPath(Utilities.addToPath(manager.getSelectedPath(), menuItem));
        }
View Full Code Here

            }
            manager.setSelectedPath(Utilities.addToPath(manager.getSelectedPath(), menuItem));
        }

        public void mouseExited(final MouseEvent e) {
            final MenuSelectionManager manager = MenuSelectionManager.defaultManager();
            manager.setSelectedPath(Utilities.removeFromPath(manager.getSelectedPath(), menuItem));
        }
View Full Code Here

            final MenuSelectionManager manager = MenuSelectionManager.defaultManager();
            manager.setSelectedPath(Utilities.removeFromPath(manager.getSelectedPath(), menuItem));
        }

        public void mouseReleased(final MouseEvent e) {
            MenuSelectionManager defaultManager = MenuSelectionManager.defaultManager();
            if (defaultManager.componentForPoint(e.getComponent(), e.getPoint()) == menuItem
                    || Utilities.isEmptyArray(defaultManager.getSelectedPath())) {

                doClick(defaultManager);
            } else {
                defaultManager.processMouseEvent(e);
            }
        }
View Full Code Here

        }
    }

    protected class MouseInputHandler implements MouseInputListener {
        public void mouseEntered(final MouseEvent e) {
            final MenuSelectionManager manager = MenuSelectionManager.defaultManager();
            if (!manager.isComponentPartOfCurrentMenu(menuItem)) {
                return;
            }
            if (Utilities.isEmptyArray(manager.getSelectedPath())) {
                return;
            }
            if (!menuItem.isEnabled()) {
                return;
            }
            if (openMenuTimer != null) {
                openMenuTimer.stop();
            }
            final JMenu menu = (JMenu)menuItem;
            MenuElement[] path = Utilities.addToPath(manager.getSelectedPath(), menu);
            if (menu.isTopLevelMenu()) {
                path = Utilities.addToPath(path, menu.getPopupMenu());
                manager.setSelectedPath(path);
                OPEN_POPUP_ACTION.openPopup(menu);
            } else {
                manager.setSelectedPath(path);
                setupPostTimer(menu);
            }
        }
View Full Code Here

            }
        }

        public void mousePressed(final MouseEvent e) {
            final JMenu menu = (JMenu)menuItem;
            MenuSelectionManager defaultManager = MenuSelectionManager.defaultManager();
            if (menu.isTopLevelMenu()) {
                if (Utilities.isEmptyArray(defaultManager.getSelectedPath())) {
                    defaultManager.setSelectedPath(new MenuElement[] {(JMenuBar)menu.getParent(), menu});
                    OPEN_POPUP_ACTION.openPopup(menu);
                } else {
                    defaultManager.clearSelectedPath();
                }
            }
        }
View Full Code Here

                }
            }
        }

        public void mouseReleased(final MouseEvent e) {
            MenuSelectionManager defaultManager = MenuSelectionManager.defaultManager();
            if (defaultManager.componentForPoint(e.getComponent(), e.getPoint()) == null) {
                defaultManager.clearSelectedPath();
            } else {
                defaultManager.processMouseEvent(e);
            }
        }
View Full Code Here

                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);
                }
            }
View Full Code Here

                    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);
                        }
                    }
View Full Code Here

TOP

Related Classes of javax.swing.MenuSelectionManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.