[jdk8u-dev] RFR: 8074883: Tab key should move to focused button in a button group [v2]
Kazuhisa Takakuri
ktakakuri at openjdk.org
Tue Sep 9 09:10:28 UTC 2025
> 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
Kazuhisa Takakuri has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
- Merge branch 'openjdk:master' into 8074883
- Merge branch 'openjdk:master' into 8074883
- Merge branch 'openjdk:master' into 8074883
- Backport eef0714323de
-------------
Changes:
- all: https://git.openjdk.org/jdk8u-dev/pull/212/files
- new: https://git.openjdk.org/jdk8u-dev/pull/212/files/c578963c..6e8415e4
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk8u-dev&pr=212&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk8u-dev&pr=212&range=00-01
Stats: 991449 lines in 2264 files changed: 934269 ins; 48303 del; 8877 mod
Patch: https://git.openjdk.org/jdk8u-dev/pull/212.diff
Fetch: git fetch https://git.openjdk.org/jdk8u-dev.git pull/212/head:pull/212
PR: https://git.openjdk.org/jdk8u-dev/pull/212
More information about the jdk8u-dev
mailing list