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

Sergey Bylokhov serb at openjdk.org
Tue Feb 21 22:31:39 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

It needs to check why the same patch caused regression in jdk9, something is missing(not backported) in jdk8? If some other patch is missing we should try to backport it first, then backport this one, and then backport the JDK-8182577.

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

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


More information about the jdk8u-dev mailing list