<Swing Dev> [9] RFR JDK-8173145: Menu is activated after using mnemonic Alt/Key combination

Mikhail Cherkasov mikhail.cherkasov at oracle.com
Mon Feb 6 13:32:14 UTC 2017


Hi all,

Bug: https://bugs.openjdk.java.net/browse/JDK-8173145
Webrev: http://cr.openjdk.java.net/~mcherkas/8173145/webrev.00/

The problem appears because AltProcessor  doesn't reset altKeyPressed 
flag when
not-alt key pressed, but event is consumed.
This situation is possible when all events consumed by key bindings. A 
menubar is activated while
user expects only key binding actions.
In my test a button should be activated by alt+m mnemonic, but a menu is 
activate, because
key pressed/released consumed by mnemonic combination and key typed 
event is
consumed by DefaultEditorKit$DefaultDeyTypedAction that is installed for 
JTextField,
as result instead of button, menu is activated.

To fix the issue I added resetting altKeyPressed flag if any non-alt key 
pressed despite consuming state,
because obviously user what make some alt+[KEY] action instead of menu 
activation.

Thanks,
Mikhail.



More information about the swing-dev mailing list