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

Alexey Ivanov alexey.ivanov at oracle.com
Tue Feb 7 15:46:15 UTC 2017


Hi Mikhail,

You should dispose the frame in the end of the test.

This could probably be removed:
  90         UIManager.getLookAndFeel();


You can merge the explicit exception list of main method to just Exception.

Otherwise, it looks good to me.


Regards,
Alexey

On 06.02.2017 16:32, Mikhail Cherkasov wrote:
> 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