JDK-6380743 : PIT: Mnemonics are broken for sub-menus and JPopupMenus in Swing
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-02-03
  • Updated: 2011-01-19
  • Resolved: 2006-02-07
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
6 b71Fixed
Related Reports
Relates :  
Relates :  
Description
None of the sub-menus open up when pressing the respective mnemonics. Same applies to popup menu as well. Mnemonics work only for the menu items. This is a regression introduced in the current AWT PIT build - b71. This works fine on b69. 

This is reproducible on all platforms. There is a mnemonic related fix in the current PIT build:
6363026: Mnemonics don't consume proper events
Not sure whether this regression is caused by the above fix. 

This is a basic feature in Swing and hence it is a blocker. 

To reproduce the bug, run the attached test. Press 'ALT + G'. The menu opens up. Press 'F'. If the sub-menu does not open up, the bug is reproduced. You can reproduce it for popup menu by right clicking inside the button. A popup menu opens up. Try navigating through the popup menu using the mnemonics shown. If none of them are accessible, bug is reproduced.
This can also be reproduced using SwingSet2. Open any menu using the mnemonic key and press the mnemonic key of any of the sub-menus. If the sub-menu does not open up, the bug is reproduced.

Comments
SUGGESTED FIX ------- BasicPopupMenuUI.java ------- *** /tmp/sccs.LlaOaL Fri Feb 3 15:19:43 2006 --- BasicPopupMenuUI.java Fri Feb 3 14:58:09 2006 *************** *** 329,341 **** menuToOpen = item; } else if (item.isEnabled()) { // we have a menu item manager.clearSelectedPath(); item.doClick(); } e.consume(); - sun.awt.SunToolkit.consumeNextKeyTyped(e); } else { // Select the menu item with the matching mnemonic. If // the same mnemonic has been invoked then select the next // menu item in the cycle. MenuElement newItem = null; --- 329,341 ---- menuToOpen = item; } else if (item.isEnabled()) { // we have a menu item manager.clearSelectedPath(); item.doClick(); + sun.awt.SunToolkit.consumeNextKeyTyped(e); } e.consume(); } else { // Select the menu item with the matching mnemonic. If // the same mnemonic has been invoked then select the next // menu item in the cycle. MenuElement newItem = null;
06-02-2006

EVALUATION It's a regression of 6363026: Mnemonics don't consume proper events. The problem is as follows. When a mnemonic KEY_PRESSED event is being handled next KEY_TYPED is consumed. But as it appeared mnemonics for Swing submenus are handled by KEY_TYPED, not by KEY_PRESSED as for menu items. Thus next KEY_TYPED event doesn't come for a submenu mnemonic. The solution is not to consume KEY_TYPED events for submenus (it's not needed) but for menu items exclusively.
03-02-2006