Java Swing Tutorial - 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.

/*from  www .  j a v a2 s . c o m*/
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);

  }
}