Package javax.swing

Examples of javax.swing.MenuSelectionManager


        static boolean menuCanceledOnPress = false;
        static JRootPane root = null;
        static Window winAncestor = null;

        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);
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;

                if (menu != null) {
                    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

  /**
   * Closes the opened submenus when scrolling starts
   */
  private void closeOpenedSubMenus()
  {
    MenuSelectionManager manager = MenuSelectionManager.defaultManager();
    MenuElement[] path = manager.getSelectedPath();
    int i = 0;
    JPopupMenu popup = getPopupMenu();

    for( ; i < path.length; i++ )
    {
      if( path[i] == popup )
      {
        break;
      }
    }

    MenuElement[] subPath = new MenuElement[i + 1];

    try
    {
      System.arraycopy( path, 0, subPath, 0, i + 1 );
      manager.setSelectedPath( subPath );
    }
    catch( Exception ekasd )
    {
    }
  }
View Full Code Here

    /*
     * Test method for 'javax.swing.plaf.basic.BasicMenuUI.setupPostTimer(JMenu)'
     */
    @SuppressWarnings("deprecation")
    public void testSetupPostTimer() throws InterruptedException, InvocationTargetException {
        final MenuSelectionManager manager = MenuSelectionManager.defaultManager();
        JFrame frame = new JFrame();
        JMenuBar menuBar = new JMenuBar();
        final JMenu menu = new JMenu("menu");
        menu.setUI(menuUI);
        ConcretePopupListener listener = new ConcretePopupListener();
        menu.getPopupMenu().addPopupMenuListener(listener);
        menu.add(new JMenuItem("item"));
        frame.setJMenuBar(menuBar);
        menuBar.add(menu);
        final JButton button = new JButton();
        frame.getContentPane().add(button);
        frame.pack();
        frame.show();
        SwingWaitTestCase.requestFocusInWindowForComponent(button);
        manager.setSelectedPath(new MenuElement[] { menuBar });
        menu.setDelay(100);
        setupTimerAntWait(menu, menuUI, listener);
        assertFalse(listener.visible);
        manager.setSelectedPath(new MenuElement[] { menuBar, menu });
        setupTimerAntWait(menu, menuUI, listener);
        assertTrue(listener.visible);
        manager.setSelectedPath(new MenuElement[] { menuBar });
        manager.setSelectedPath(new MenuElement[] { menuBar, menu });
        menu.setDelay(10000);
        setupTimerAntWait(menu, menuUI, listener);
        assertFalse(listener.visible);
    }
View Full Code Here

        menu.add(item);
        frame.getContentPane().add(menuBar);
        frame.pack();
        frame.show();
        assertEquals(0, menuItemUI.getPath().length);
        MenuSelectionManager manager = MenuSelectionManager.defaultManager();
        manager.setSelectedPath(new MenuElement[] { menuBar, menu, menu.getPopupMenu(), item });
        assertEquals(4, menuItemUI.getPath().length);
        assertSame(menuBar, menuItemUI.getPath()[0]);
        assertSame(menu, menuItemUI.getPath()[1]);
        assertSame(menu.getPopupMenu(), menuItemUI.getPath()[2]);
        assertSame(item, menuItemUI.getPath()[3]);
        manager
                .setSelectedPath(new MenuElement[] { menuBar, item2, menu2, menu.getPopupMenu() });
        assertEquals(5, menuItemUI.getPath().length);
        assertSame(menuBar, menuItemUI.getPath()[0]);
        assertSame(item2, menuItemUI.getPath()[1]);
        assertSame(menu2, menuItemUI.getPath()[2]);
        assertSame(menu.getPopupMenu(), menuItemUI.getPath()[3]);
        assertSame(item, menuItemUI.getPath()[4]);
        manager.setSelectedPath(new MenuElement[] { menuBar });
        assertEquals(1, menuItemUI.getPath().length);
        assertSame(item, menuItemUI.getPath()[0]);
        manager.clearSelectedPath();
        assertEquals(0, menuItemUI.getPath().length);
        frame.dispose();
    }
View Full Code Here

            @Override
            public void doClick(final int pressTime) {
                time = pressTime;
            }
        }
        MenuSelectionManager manager = new MenuSelectionManager();
        manager.setSelectedPath(new MenuElement[] { new JMenu(), new JMenu() });
        MyJMenuItem item = new MyJMenuItem();
        item.setUI(menuItemUI);
        menuItemUI.doClick(manager);
        assertEquals(0, manager.getSelectedPath().length);
        assertEquals(0, item.time);
    }
View Full Code Here

public class FlyScanMenuItemUI extends BasicMenuItemUI {

    @Override
    public MenuElement[] getPath() {

        MenuSelectionManager m = MenuSelectionManager.defaultManager();
        MenuElement oldPath[] = m.getSelectedPath();
        MenuElement newPath[];
        int pathLength = oldPath.length;

        if (pathLength == 0)
            return new MenuElement[0];
View Full Code Here

     * Test method for 'javax.swing.event.MenuKeyEvent.getPath()'
     */
    public void testGetPath() {
        MenuElement[] path = new MenuElement[1];
        event = new MenuKeyEvent(new JMenuItem(), 1, 2, 3, 4, 'a', path,
                new MenuSelectionManager());
        assertSame(path, event.getPath());
        event = new MenuKeyEvent(new JMenuItem(), 1, 2, 3, 4, 'a', null,
                new MenuSelectionManager());
        assertSame(null, event.getPath());
    }
View Full Code Here

        static boolean menuCanceledOnPress = false;
        static JRootPane root = null;
        static Window winAncestor = null;

        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);
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.