[jdk8u-dev] RFR: 8074883: Tab key should move to focused button in a button group

ktakakuri duke at openjdk.org
Fri Jan 13 10:02:31 UTC 2023


On Fri, 16 Dec 2022 10:30:19 GMT, ktakakuri <duke at openjdk.org> wrote:

> This is a backport of JDK-8074883: Tab key should move to focused button in a button group.
> 
> I would like to backport the patch to OpenJDK8u.
> Original patch does not apply cleanly to 8u, because the fix uses a new API published in JDK9.
> 
> * Since RequestFocusController only determines whether or not to set focus, I modified it so that requestFocus/requestFocusInWindow is called by SwingUtilities.invokeLater() and re-set focus and return false.
> Without invokeLater(), the focus returns to the first button in case of Cause.ACTIVATION.
> 
> * ToggleButton.getGroupSelection() is defined as a package private method, because it must be called by JCompoennt.focusController.
> 
> * Calling requestFocus()/requestFocusInWindow() will be processed as Cause.UNKNOWN.
> ToggleButton.getGroupSelection() returns itself, so no circular call occurs.
> 
> * I moved Component.requestFocusController.acceptRequestFocus because RequestFocusContoroller is not called when Cause.ACTIVATION.
> 
> * Only Swing components replace default RequestFocusController to JComponent.focusController.
> The focusController returns true except for Swing, so this change does not affect other components.
> 
> Testing:
>  build on Windows x86_64
>  java/awt, javax/swing and ButtonGroupFocusTest.java on Windows x86_64

DefaultButtonModelCrashTest passed even before this backport was applied.
Does this mean that JDK-8182577 is already fixed in 8u?

-------------

PR: https://git.openjdk.org/jdk8u-dev/pull/212


More information about the jdk8u-dev mailing list