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

Mnemonic disappears after repeated attempts to open menu items using mnemonics

    Details

    • Subcomponent:
    • Resolved In Build:
      b61
    • CPU:
      x86
    • OS:
      windows_xp

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.6.0_15"
        Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
        Java HotSpot(TM) Client VM (build 14.1-b02, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows XP [Version 5.1.2600]

        A DESCRIPTION OF THE PROBLEM :
        Mnemonic disappears after repeated attempts to open menu items using mnemonic key:

        Problem:
        When you press a sequence of hot keys/ mnemonics, Panels stop displaying the Mnemonics for the menu items.

        Sample scenario, press Alt+F, Alt+S (No action in between like mouse click or esc) the Mnemonics letters doesn't get displayed. (chose 'F' & 'S' as sample code below use same mnemonics.

        Problem is reproducible only with "SystemLAF", but if we use "Metal/Motif LAF" then we do not have this problem as the menus appear differently.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Sample scenario, press Alt+F, Alt+S (No action in between like mouse click or esc) the Mnemonics letters doesn't get displayed. (chose 'F' & 'S' as sample code below use same )won't get displayed, after the very first time for which mnemonics get displayed.




        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Expected Results:
        No matter how many ever times the mnemonics/hot keys are tried to access by pressing Alt+F or Alt+(any mnemonic present in menu item),particular mnemonic should get displayed/underlined properly.

        ACTUAL -
        Actual Result:
        Alt+(any mnemonic present in menu item). it should get displayed/underlined every time the operation is performed.

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        No error messages logged.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------

        import java.awt.event.ActionEvent;
        import java.awt.event.ActionListener;
        import java.awt.event.KeyEvent;

        import javax.swing.JFrame;
        import javax.swing.JMenu;
        import javax.swing.JMenuBar;
        import javax.swing.JMenuItem;
        import javax.swing.UIManager;
        import javax.swing.UnsupportedLookAndFeelException;



        class MenuActionListener implements ActionListener {
          public void actionPerformed(ActionEvent actionEvent) {
            System.out.println("Selected: " + actionEvent.getActionCommand());
          }
        }

        public class MenuLookDemo {

          public static void main(final String args[]) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
            ActionListener menuListener = new MenuActionListener();
            JFrame frame = new JFrame("Menu Look Demo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            
            JMenuBar menuBar = new JMenuBar();
            
            // used to set to Windows LAF
            String systemLAF;
            systemLAF = UIManager.getSystemLookAndFeelClassName();
            UIManager.setLookAndFeel(systemLAF);
            

            // First Menu, F - Mnemonic
            JMenu firstMenu = new JMenu("Fisrt Menu");
            firstMenu.setMnemonic(KeyEvent.VK_F);
            menuBar.add(firstMenu);
           

            // Fisrt Menu - menu items
            JMenuItem oneMenuItem = new JMenuItem("One", KeyEvent.VK_O);
            oneMenuItem.addActionListener(menuListener);
            firstMenu.add(oneMenuItem);

            JMenuItem twoMenuItem = new JMenuItem("Two", KeyEvent.VK_T);
            twoMenuItem.addActionListener(menuListener);
            firstMenu.add(twoMenuItem);
            
            // Second Menu, S - Mnemonic
            JMenu secondMenu = new JMenu("Second Menu");
            secondMenu.setMnemonic(KeyEvent.VK_S);
            menuBar.add(secondMenu);
            
            // Second Menu - menu items
            JMenuItem anotherMenuItem = new JMenuItem("Another Menu Item", KeyEvent.VK_A);
            anotherMenuItem.addActionListener(menuListener);
            secondMenu.add(anotherMenuItem);

            frame.setJMenuBar(menuBar);
            frame.setSize(350, 250);
            frame.setVisible(true);
          }
        }


        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Workaround:
        Disabling Windows Keyboard Navigation checkbox on display setting, will always shows mnemonics. I just tried to disable this option (control panel->display->Appearance->effects-> Hide underlined letters for keyboard Navigation until i press the Alt Key) and mnemonics always appears and able to use it properly.

        SUPPORT :
        YES

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ssadetsky Semyon Sadetsky
                  Reporter:
                  igor Igor Nekrestyanov (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: