<Swing Dev> RFR: 8249548: backward focus traversal gets stuck in button group
Pankaj Bansal
pankaj.b.bansal at oracle.com
Sun Jul 26 10:54:58 UTC 2020
Hi All,
Please review the following fix for jdk16.
Bug : https://bugs.openjdk.java.net/browse/JDK-8249548
webrev: http://cr.openjdk.java.net/~pbansal/8249548/webrev00/
<http://cr.openjdk.java.net/%7Epbansal/8249548/webrev00/>
Issue: If few ToggleButtons are added to button group, the backward
focus traversal can get stuck in few scenarios while using
LayoutFocusTraversalPolicy. For exaple, if a TextField is added to a
frame and a Button Group is added with two buttons and the second button
in set selected, we can not move the focus from Button Group to Text
Field using "Shift+Tab". More details in JBS.
Cause: The LayoutFocusTraversalPolicy uses SortingFocusTraversalPolicy
always selects first button for focus traversal in button group for
Toggle Button. This can be changed by Component if one of the button in
the button group is set selected. This results in the selected Button
being selected again and again for selection on pressing "Shift+Tab".
This results in focus being stuck at same position. This is a generic
issue and it is observed in all L&F for JToggleButton.
The JRadioButton does not have this issue as BasicRadioButtonUI and
AquaRadioButtonUI have code to handle this issue but the Synth L&F has
this issue for JRadioButton also. So, this issue can be observed in both
ToggleButton and RadioButton in nimbus L&F.
Fix: The fix is to add the code to handle this in BasicButtonUI class,
so that it is available for all L&F without copying it in different L&F
classes. The focus traversal works fine after this change for all L&F
for both ToggleButton and RadioButton. Along with the current problem,
this fix is also fixes issue like we cant change the selected button and
focus in ToggleButton group like RadioButton group.
An automated test is added. I have ran the Mach5 with all tests and this
is not causing any failures. Links in JBS.
Regards
Pankaj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/swing-dev/attachments/20200726/c236a0ca/attachment.htm>
More information about the swing-dev
mailing list