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

Keyboard Navigation in RadioButton-Group Not Possible

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • tbd
    • 9, 10, 11, 12, 13, 14
    • client-libs
    • None
    • 9
    • windows

      Navigation/selection with keyboard of each JRadioButton in a ButtonGroup is not possible when a Synth based Look and Feel like Nimbus is used. The test below demonstrates the issue- the issue was introduced with Java 9. The relevant code is in located in BasicRadioButtonUI - it looks like KeyHandler and actions haven't been ported to SynthRadioButtonUI for some reason.


      public class RadioButtonGroupTest extends JFrame
      {
        public RadioButtonGroupTest()
        {
          setName(getClass().getSimpleName());
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setLayout(new FlowLayout());

          final JRadioButton one = new JRadioButton("one");
          final JRadioButton two = new JRadioButton("two");
          final JRadioButton three = new JRadioButton("three");
          add(one);
          add(two);
          add(three);
          add(new JButton("hello"));

          final ButtonGroup grp = new ButtonGroup();
          grp.add(one);
          grp.add(two);
          grp.add(three);
          setSize(300, 400);
          setLocationRelativeTo(null);
          setVisible(true);
        }
        
        public static void main(final String[] args) throws Exception
        { UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
          SwingUtilities.invokeLater(() -> new RadioButtonGroupTest());
        }
      }

            psadhukhan Prasanta Sadhukhan
            wzberger Wolfgang Zitzelsberger
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: