Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6676102

Duplicate mnemonics on menus and menu items highlight incorrect menu item

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • client-libs

      FULL PRODUCT VERSION :
      java version "1.6.0_03"
      Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
      Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP version 5.1.2600
      Microsoft Windows version 5.2.3790

      A DESCRIPTION OF THE PROBLEM :
      Cycling through menus and menu items with the same mnemonic char highlights the incorrect menu item. In the attached example there is a menu Test with two menu items followed by one sub menu and then two more menu items. Each menu item and the sub menu have the mnemonic character 'm'.

      Opening the Test menu with ALT-T and pressing the 'm' character will select the second menu item. Pressing 'm' once again will select the menu 'Sub-menu'. Pressing 'm' a third time will select the first menu item, not the third menu item as expected.

      In this example you cannot navigate to the last two menu items using their mnemonics.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
          public static void main(String[] args) throws Exception {
              UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
              JMenu menu = new JMenu("Test");
              menu.setMnemonic('T');
              menu.add( new JMenuItem("Menu item 1", "M".charAt(0)) );
              menu.add( new JMenuItem("Menu item 2", "M".charAt(0)) );
              JMenu subMenu = new JMenu("Sub-menu");
              subMenu.setMnemonic('m');
              subMenu.add( new JMenuItem("sub menu item 1", "s".charAt(0)) );
              subMenu.add( new JMenuItem("sub menu item 2", "s".charAt(0)) );
              menu.add( subMenu );
              menu.add( new JMenuItem("Menu item 3", "M".charAt(0)) );
              menu.add( new JMenuItem("Menu item 4", "M".charAt(0)) );

              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              JMenuBar menuBar = new JMenuBar();
              menuBar.add( menu );
              frame.setJMenuBar( menuBar );
              frame.pack();
              frame.setVisible( true );
          }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Refrain from using duplicate mnemonics in a menu.

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: