Add a WindowListener
to the JDialog
, and on windowClosed
set a boolean or something when it is closed. Also have a buttonClicked
boolean, if they clicked the button it would be true, if they clicked the exit button at the top of the window it would be false.
boolean closed;
boolean buttonClicked;
JButton exitbutton;
JDialog dialog;
...
public void actionPerformed(ActionEvent arg0) {
buttonClicked = true;
dialog.dispose();
}
...
dialog.addWindowListener(new WindowListener() {
public void windowActivated(WindowEvent arg0) {
// Do nothing
}
public void windowClosed(WindowEvent arg0) {
closed = true;
if(buttonClicked) {
//They cliked the button to close it.
} else {
// They didn't click the button, they clicked exit in the top right corner of screen.
}
}
public void windowClosing(WindowEvent arg0) {
// Do nothing
}
public void windowDeactivated(WindowEvent arg0) {
// Do nothing
}
public void windowDeiconified(WindowEvent arg0) {
// Do nothing
}
public void windowIconified(WindowEvent arg0) {
// Do nothing
}
public void windowOpened(WindowEvent arg0) {
// Do nothing
}
});