i have a class (Class ButtonX) that contains a button
when user clicks the button, it will create instance of the class DialogX
when I create instance of the class DialogX
it will show up 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();
}
}
listener of that JButton
public class ListenerX {
public static ActionListener listen = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
DialogX dialogx = null;
dialogx = new DialogX();
}};
}
class that contains 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);
}
}
what I try to achieve is, that when user clicks the button, it will destroy instance of class DialogX
( if it exist ) and then create again instance of DialogX
What to do?
thanks..
forgive my english..