For my custom JDialog,
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
has been set.
There is a button on the JDialog. Based on a condition, it calls dialog.dispose().
Both these actions trigger the windowClosed event. But I want to identify it reached there because the close button was clicked or because the dispose method was invoked.
Add a
WindowListenerto theJDialog, and onwindowClosedset a boolean or something when it is closed. Also have abuttonClickedboolean, 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.