Define a RadioButton:
JRadioButton rbtn1=new JRadioButton("txt1",true);
JRadioButton rbtn2=new JRadioButton("txt2",false);
JRadioButton rbtn3=new JRadioButton("txt3",false);
Button Group Creation:
ButtonGroup grupo1 = new ButtonGroup();
grupo1.add(rbtn1);
grupo1.add(rbtn2);
grupo1.add(rbtn3);
The Class that is used is called JRadioButton The parameters that are passed at the moment of creating it are the Text that will be carried and if this item will be selected when executing our program.
examples:
rbtn1.setText("Texto");
rbtn1.setSelected(true);
to perform an action:
if(rbtn1.isSelected()==true)
{
System.out.print("Seleccionó opción 1");
}