Код: Выделить всё
this.addWindowListener(new WindowDestroyer(this));
Код: Выделить всё
public class WindowDestroyer extends WindowAdapter implements ActionListener
{
private ActionListener c;
private MessageBox msg; //my class
public WindowDestroyer(ActionListener c)
{
this.c=c;
}
public void windowClosing(WindowEvent e)
{
msg = new MessageBox(c);
msg.askOKCancel("Are you shure you want to exit?");
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("Cancel"))
msg.closeMessageBox();
}
}