Java JRadioButton() Constructor

Syntax

JRadioButton() constructor from JRadioButton has the following syntax.

public JRadioButton()

Example

In the following code shows how to use JRadioButton.JRadioButton() constructor.


/* w w  w  .  j  a va  2  s  . com*/
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);

  }
}