ボタンを含むクラス(Class ButtonX)があります
ユーザーがボタンをクリックすると、クラスのインスタンスが作成されますDialogX
クラスのインスタンスを作成すると、DialogX
それが表示されますJDialog
public class ButtonX {
public ButtonX() {
JFrame me = new JFrame();
JButton n = new JButton("show dialog");
n.addActionListener(ListenerX.listen);
me.getContentPane().add(n);
me.pack();
me.setVisible(true);
}
public static void main (String[]args){
new ButtonX();
}
}
その聞き手JButton
public class ListenerX {
public static ActionListener listen = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
DialogX dialogx = null;
dialogx = new DialogX();
}};
}
含むクラスJDialog
public class DialogX {
static JDialog g = new JDialog();
public DialogX() {
JLabel label = new JLabel("label");
g.getContentPane().setLayout(new FlowLayout());
g.getContentPane().add(label);
g.pack();
g.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
g.setVisible(true);
}
}
私が達成しようとしているのは、ユーザーがボタンをクリックすると、クラスのインスタンスDialogX
(存在する場合) を破棄し、インスタンスを再度作成することです。DialogX
何をすべきか?
ありがとう..
私の英語を許して..