Why is my panel not positioned correctly even after setting the boundaries?
- by nutellafella
I'm trying to make a simple GUI with radio buttons and I grouped them into one panel. I wanted it positioned on the leftmost side so I used the setBounds method. Whatever numbers I put on the parameters, the panel won't move. Are panels not affected by the setBounds method? Or is there another way to position my panel. Here's the snippet of my code:
JPanel radioPanel = new JPanel();
radioPanel.setLayout(new GridLayout(3,1));
JRadioButton Rbutton1 = new JRadioButton("Credit Card");
JRadioButton Rbutton2 = new JRadioButton("E-Funds");
JRadioButton Rbutton3 = new JRadioButton("Check");
Rbutton3.setSelected(true);
ButtonGroup Bgroup = new ButtonGroup();
Bgroup.add(Rbutton1);
Bgroup.add(Rbutton2);
Bgroup.add(Rbutton3);
radioPanel.add(Rbutton1);
radioPanel.add(Rbutton2);
radioPanel.add(Rbutton3);
radioPanel.setBounds(10,50,50,40); //this is where I'm trying to position the panel with the radio buttons
paymentPanel.add(radioPanel);
contentPane.add(paymentPanel); //contentPane is the frame
contentPane.setVisible(true);