How to call a method when JDialog window is closing?

i want to call a method when the JDialog is closing?.
i have tried with
protected void processWindowEvent(WindowEvent evt).
but it is not entering into that method while closing the window.
please give me a sample code

/**
* To shutdown when run as an application. This is a
* fairly lame implementation. A more self-respecting
* implementation would at least check to see if a save
* was needed.
*/
protected static final class AppCloser extends WindowAdapter {
public void windowClosing(WindowEvent e) {
// your actions after closing the window
//System.exit(0);
}
}

It's snip of code for application. But it will work for your JDialog as well.

There is another way if your JDialog is being called from some other component...oh, lets say...a JFrame?

The call to the JDialog is triggered somewhere in that code, or any other controlling class that you might have. They you only have to make that call directly after the control returns from the JDialog. There are many different possiblities. You can set a boolean variable to be changed if the proper actions were taken, if not correctly performed then trigger the new method--ie a JOptionPane message.

I usually get rid of the JDialog with the 'dispose();' method, returning control to the calling class.

But since you are wanting to close the program entirely with a system exit, then this is just food for thought.

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed.
------------------------- Start
The idea here is to target your cell phones with
the correct…

Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java.
Define …