Java ButtonGroup .setSelected (ButtonModel m, boolean b)

Syntax

ButtonGroup.setSelected(ButtonModel m, boolean b) has the following syntax.

public void setSelected(ButtonModel m,  boolean b)

Example

In the following code shows how to use ButtonGroup.setSelected(ButtonModel m, boolean b) method.


/*from w w  w .j a v  a2 s.co  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);

  }
}