JDK-6217905 : JPopupMenu keyboard navigation stops working
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0,5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_nt,windows_xp
  • CPU: x86
  • Submitted: 2005-01-14
  • Updated: 2014-09-23
  • Resolved: 2011-05-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u10Fixed 7 b20Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
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

Comments
Will issue JDK-4740942 be fixed in jdk 5?
23-09-2014

EVALUATION This bug is tightly coupled with the bug #4740942 so the the fix will solve both problems First - we should not select the fist item in popups by default (see #4740942 for details) Windows and GTK don't do that commercial java applications like Idea fixes this bug by themselves and doesn't automatically select the first item for popups as well, neither does Mozilla applications the only GUI toolkit which behaves differently is Motif I believe that we should fix 4740942 and provide this behaviour by default all LaF will benefit from that (except Motif which is obsolete and is not supported by now) The keyboard navigation will also be fixed
04-07-2007

EVALUATION Contribution forum : https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?forumID=1463&messageID=13487
08-06-2006