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?