JDK-8129940 : JRadioButton does not honor non-standard FocusTraversalKeys
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u40,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • Submitted: 2015-06-23
  • Updated: 2022-04-19
  • Resolved: 2015-07-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8 JDK 9
7u321Fixed 8u311Fixed 9 b74Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.3.9600]

A DESCRIPTION OF THE PROBLEM :
The JFrame is defined to treat ENTER as a forward traversal key equivalent to TAB:

        Set<KeyStroke> keystrokes = new HashSet<KeyStroke>();
        keystrokes.add(KeyStroke.getKeyStroke("TAB"));
        keystrokes.add(KeyStroke.getKeyStroke("ENTER"));
        frame.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, keystrokes);

This works correctly in all versions of Java on all platforms through 8u31.  In 8u40, 8u45, and 8u60-ea on Windows, radio buttons do not honor non-standard FocusTraversalKeys.

REGRESSION.  Last worked in version 8u31

ADDITIONAL REGRESSION INFORMATION: 
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached sample in 8u40 or higher in Windows.

Press ENTER to navigate through the components.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected ENTER to work as a forward traversal key on all components.
ACTUAL -
The text components correctly recognize both TAB and ENTER as a forward traversal key; the radio buttons only recognize TAB.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.util.*;
import javax.swing.*;

public class FocusTraversalTest
{
    public static void main(String[] args) throws Exception
    {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        JFrame frame = new JFrame("FocusTraversalTest");
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        Set<KeyStroke> keystrokes = new HashSet<KeyStroke>();
        keystrokes.add(KeyStroke.getKeyStroke("TAB"));
        keystrokes.add(KeyStroke.getKeyStroke("ENTER"));
        frame.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, keystrokes);

        JRadioButton a = new JRadioButton("a");
        JRadioButton b = new JRadioButton("b");
        JRadioButton c = new JRadioButton("c");
        JRadioButton d = new JRadioButton("d");

        ButtonGroup radioButtonGroup = new ButtonGroup();
        radioButtonGroup.add(a);
        radioButtonGroup.add(b);
        radioButtonGroup.add(c);
        radioButtonGroup.add(d);

        JPanel panel = new JPanel();
        panel.add(new JTextField("text"));
        panel.add(new JTextField("text"));
        panel.add(a);
        panel.add(b);
        panel.add(c);
        panel.add(d);
        panel.add(new JTextField("text"));
        panel.add(new JTextField("text"));

        JPanel root = new JPanel();
        root.setLayout(new BorderLayout());
        root.add(panel, BorderLayout.CENTER);
        root.add(new JButton("OK"), BorderLayout.SOUTH);

        frame.add(root);
        frame.pack();
        frame.setVisible(true);
    }
}

---------- END SOURCE ----------


Comments
A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk8u-dev/pull/41 Date: 2022-04-19 14:28:13 +0000
19-04-2022

Adding jdk8u-needs-pr. This fix needs to be rebased on to the current GitHub 8u-dev repository - https://github.com/openjdk/jdk8u-dev - and reviewed there before being approved and integrated.
14-04-2022

8u code review: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2021-June/014026.html
25-06-2021

URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/fbf897c33625 User: lana Date: 2015-07-22 21:33:50 +0000
22-07-2015

URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/fbf897c33625 User: ssadetsky Date: 2015-07-07 06:57:14 +0000
07-07-2015

This is a regression from JDK 8u40. 1. Run the attached test case (FocusTraversalTest.java) in Windows 7 (64-bit). 2. Checked this for JDK 8u31, 8u40, 8u45, 8u60 ea b19, and 9 ea b69. Result: ----------- 8: OK 8u31: OK 8u40: FAIL 8u45: FAIL 8u60 ea b19: FAIL 9 ea b69: FAIL 3. As reported by the submitter, this is a regression. This works correctly IN JDK 8 and subsequent until 8u40. However, in 8u40, 8u45, and 8u60-ea on Windows, radio buttons do not honour non-standard FocusTraversalKeys. Moving this up for further evaluation.
26-06-2015

regression of JDK-8033699
26-06-2015