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

JPopupMenu keyboard navigation stops working

XMLWordPrintable

    • b20
    • x86
    • windows_nt, windows_xp
    • Not verified

        FULL PRODUCT VERSION :
        java version "1.5.0"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
        Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)

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

        A DESCRIPTION OF THE PROBLEM :
        Run the testcase, scroll the mouse over choice 1, choice 2, choice 3 then continue vertically until the JMenuPopup has no entry selected. Now try using the keyboard arrow keys to change the menu selection. This will fail.

        You can experiment and you will notice that keyboard navigation works properly until the mouse causes the JPopupMenu selection to clear (i.e. no entry selected). There is no way to bring back keyboard navigation without using the mouse.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        It should be possible to bring back menu focus, selection by using the keyboard. Use notification-area popups as an example of how this should work.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.awt.event.ActionEvent;
        import java.awt.event.ActionListener;
        import javax.swing.JFrame;
        import javax.swing.JMenuItem;
        import javax.swing.JPopupMenu;

        public class Test
        {
          public static void main(String[] args)
          {
            JFrame invoker = new JFrame();
            JPopupMenu popupMenu = new JPopupMenu();
            JMenuItem menuItem = new JMenuItem("choice 1");
            ActionListener actionListener = new ActionListener()
            {
              public void actionPerformed(ActionEvent e)
              {
                JMenuItem menuItem = (JMenuItem) e.getSource();
                System.out.println(menuItem.getText());
              }
            };
            menuItem.addActionListener(actionListener);
            popupMenu.add(menuItem);
            menuItem = new JMenuItem("choice 2");
            menuItem.addActionListener(actionListener);
            popupMenu.add(menuItem);
            menuItem = new JMenuItem("choice 3");
            menuItem.addActionListener(actionListener);
            popupMenu.add(menuItem);
            invoker.setUndecorated(true);
            invoker.setSize(popupMenu.getPreferredSize());
            invoker.setVisible(true);
            
            popupMenu.show(invoker, 0, 0);
          }
        }
        ---------- END SOURCE ----------
        ###@###.### 2005-1-14 23:35:49 GMT

              alexp Alexander Potochkin (Inactive)
              gmanwanisunw Girish Manwani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: