I know this is simple, but I just can't find the solution (and Code Guru's search feature seems to be broken as clicking on it produces an endless wait)

I want the ability to reject the exiting of an app. When the user exists, I want to display a message that allows the user to cancel the exit request.

I have had no luck. First off, this has such vague, general words that search results produce little more than completely unrelated topics. Other results advise listening for the windowClosing() event provided by WindowAdapter / WindowListener. This fails for 2 reasons:

1) Closing the app with "System.exit( X )" does not result in this event being fired.

2) windowClosing() does not allow you to reject the closing. All it does is tell you that it happened (when it even bothers to tell you that), but there is no way to reject it.


What do I need to do?