Hello friend,
I suggets yout to study follwing example of JPanel class. This java example will show you the use of JPanel class:
Code:
import javax.swing.JPanel;
import javax.swing.JRadioButton;
public class JPdemo extends JPanel {
public MainClass() {
JRadioButton radMarriedYes1 = new JRadioButton("Yes?", true);
JRadioButton radMarriedNo1 = new JRadioButton("No?", false);
ButtonGroup radioGroup01 = new ButtonGroup();
setLayout(null);
add(radMarriedYes1);
add(radMarriedNo1);
radioGroup01.add(radMarriedYes1);
radioGroup01.add(radMarriedNo1);
radMarriedYes1.setBounds(40, 50, 50, 20);
radMarriedNo1.setBounds(40, 80, 50, 20);
}
public static void main(String[] args) {
JFrame frame2 = new JFrame();
frame2.getContentPane().add(new MainClass());
frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame2.setSize(200, 200);
frame2.setVisible(true);
}
}
Bookmarks