ラジオ ボタンを使用してシンプルな GUI を作成しようとしていて、それらを 1 つのパネルにグループ化しました。一番左側に配置したかったので、setBounds メソッドを使用しました。パラメータにどんな数字を入れても、パネルは動きません。パネルは setBounds メソッドの影響を受けませんか? または、パネルを配置する別の方法がありますか。これが私のコードのスニペットです:
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);