あなたがする必要があるのは、 の選択に表示したい余分なコンポーネントを追加し、YES JRadioButtonそれらをすべて に配置することJPanelです。
を選択したら、以下の例に示すように、YES JRadioButtonこれを に追加JPanelしてJPanel, that is holding both the JRadioButton and this newly created JPanel、 を呼び出します。frame.pack()
private ActionListener radioActions = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == yesRButton)
{
if (!selectionPanel.isShowing())
contentPane.add(selectionPanel);
}
else if (e.getSource() == noRButton)
{
if (selectionPanel.isShowing())
contentPane.remove(selectionPanel);
}
frame.pack();
}
};