Reputation: 1
i was trying to create two radiobuttons in the frame using swing concept .. here is my code
import javax.swing.*;
class abc
{
abc()
{
JFrame j=new JFrame();
JRadioButton jb1=new JRadioButton("a)first");
JRadioButton jb2=new JRadioButton("b)Second");
jb1.setBounds(50,100,70,30);
jb1.setBounds(50,150,70,30);
ButtonGroup b=new ButtonGroup();
b.add(jb1);
b.add(jb2);
j.add(jb1);
j.add(jb2);
j.setSize(500, 500);
j.setLayout(null);
j.setVisible(true);
}
}
public class Swingss
{
public static void main(String[] args)
{
new abc();
}
}
but i got only one radio button inside the frame ... may i know where i did the mistake
Upvotes: 0
Views: 44
Reputation: 15310
You mistyped jb1
twice instead of jb2
:
jb1.setBounds(50,100,70,30);
jb1.setBounds(50,150,70,30); // -> jb2
Upvotes: 1