PROGRAM:
~~~~~~~~~~~
import javax.swing.*;
import java.awt.*;
class radio extends JFrame
{
private static final long serialVersionUID = 1L;
Container con;
JRadioButton r1,r2;
ButtonGroup bg;
radio()
{
con=getContentPane();
con.setLayout(null);
r1=new JRadioButton("Male");
r2=new JRadioButton("Female");
bg=new ButtonGroup();
bg.add(r1);
bg.add(r2);
r1.setBounds(200,200,90,30);
r2.setBounds(200,250,90,30);
con.add(r1);
con.add(r2);
}
public static void main(String[] arg)
{
radio obj=new radio();
obj.setVisible(true);
obj.setSize(400,400);
obj.setTitle("This is my frame");
}
}
~~~~~~~~~~~
import javax.swing.*;
import java.awt.*;
class radio extends JFrame
{
private static final long serialVersionUID = 1L;
Container con;
JRadioButton r1,r2;
ButtonGroup bg;
radio()
{
con=getContentPane();
con.setLayout(null);
r1=new JRadioButton("Male");
r2=new JRadioButton("Female");
bg=new ButtonGroup();
bg.add(r1);
bg.add(r2);
r1.setBounds(200,200,90,30);
r2.setBounds(200,250,90,30);
con.add(r1);
con.add(r2);
}
public static void main(String[] arg)
{
radio obj=new radio();
obj.setVisible(true);
obj.setSize(400,400);
obj.setTitle("This is my frame");
}
}