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

ktakakuri duke at openjdk.org
Tue Feb 21 02:33:30 UTC 2023


On Sat, 14 Jan 2023 04:17:04 GMT, Sergey Bylokhov <serb 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
>
> One of the comment in the JDK-8182577 mentioned that that test works fine in jdk8 and failed since jdk9. So that was a regression, possibly caused by the change you requested to backport or maybe some other.

@mrserb 
Is there anything else that needs to be confirmed?

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

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


More information about the jdk8u-dev mailing list