Selecting a JRadioButton Component in a Button Group : Radio Button « Swing JFC « Java






Selecting a JRadioButton Component in a Button Group

  

import javax.swing.ButtonGroup;
import javax.swing.ButtonModel;
import javax.swing.JRadioButton;

public class Main {
  public static void main(String[] argv) throws Exception {

    JRadioButton radioButton = new JRadioButton();
    ButtonGroup group = new ButtonGroup();
    ButtonModel model = radioButton.getModel();
    group.setSelected(model, true);

  }
}

   
    
  








Related examples in the same category

1.Creating a JRadioButton Component
2.Radio Button Mnemonic KeyRadio Button Mnemonic Key
3.Using JRadioButtonsUsing JRadioButtons
4.A ButtonGroup voting boothA ButtonGroup voting booth
5.RadioButton DemoRadioButton Demo
6.React Radio button eventReact Radio button event
7.Working with the JRadioButtonWorking with the JRadioButton
8.ButtonGroup DemoButtonGroup Demo
9.Group RadioButtonGroup RadioButton
10.Group Action RadioButtonGroup Action RadioButton
11.Implement group of buttons in an application
12.A frame with a sample text label and radio buttons for selecting font sizesA frame with a sample text label and radio buttons for selecting font sizes