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: 2015-10-27
  • 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 9
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
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