Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8129940

JRadioButton does not honor non-standard FocusTraversalKeys

    Details

    • Subcomponent:
    • Resolved In Build:
      b74
    • OS:
      generic

      Backports

        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 ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ssadetsky Semyon Sadetsky (Inactive)
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: