List of usage examples for javax.swing ButtonGroup clearSelection
public void clearSelection()
ButtonGroup
are selected. From source file:Main.java
public Main() { JRadioButton radMarriedYes = new JRadioButton("Yes?", true); JRadioButton radMarriedNo = new JRadioButton("No?", false); JRadioButton radGolfYes = new JRadioButton("Yes?", false); JRadioButton radGolfNo = new JRadioButton("No?", true); ButtonGroup radioGroup1 = new ButtonGroup(); ButtonGroup radioGroup2 = new ButtonGroup(); setLayout(null);//from w ww. j a v a2 s. c o m add(radMarriedYes); add(radMarriedNo); add(radGolfYes); add(radGolfNo); radioGroup1.add(radMarriedYes); radioGroup1.add(radMarriedNo); radioGroup1.clearSelection(); radioGroup2.add(radGolfYes); radioGroup2.add(radGolfNo); radMarriedYes.setBounds(30, 50, 50, 20); radMarriedNo.setBounds(30, 80, 50, 20); radGolfYes.setBounds(150, 50, 50, 20); radGolfNo.setBounds(150, 80, 50, 20); }