I need to stop the default operation of window being closed when red x mark is clicked on the swing window. I am using the JDialog and adding WindowsListener to it to capture the WindowClosing event, there I decide whether to dispose JDialog or to not dispose it, I am also setting the following:
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
But still when I click on the red x mark, the window closes. Any ideas?
Adding Window listener to the JDialog gave me the power to handle the window actions and I works fine in my application.
You can try creating a WindowListener and do nothing when the close buttion is clicked.