When I run the code below, the first 2 buttons do not appear; however, the third one is visible in the frame.
public class RadioButton {
RadioButton(){
JFrame frame = new JFrame();
JRadioButton button1 = new JRadioButton("One");
button1.setBounds(50, 20, 50, 20);
JRadioButton button2 = new JRadioButton("Two");
button2.setBounds(50, 50, 50, 20);
JRadioButton button3 = new JRadioButton("Three");
button2.setBounds(50, 80, 50, 20);
ButtonGroup bg = new ButtonGroup();
bg.add(button1);
bg.add(button2);
bg.add(button3);
frame.add(button1);
frame.add(button2);
frame.add(button3);
frame.setSize(300, 300);
frame.setVisible(true);
frame.setLayout(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new RadioButton();
}
}