あなたがする必要があるのは、 の選択に表示したい余分なコンポーネントを追加し、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();
}
};