Link to home
Start Free TrialLog in
Avatar of mmsreddy
mmsreddy

asked on

How to call a method when JDialog window is closing?


Hi

    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

thanks
ASKER CERTIFIED SOLUTION
Avatar of Valeri
Valeri
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tomboshell
tomboshell

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.

Tom