jkteater
asked on
Closing / Terminating a dialog window
My code is calling and opening a dialog window. I am wanting to call a method when the user either hits the cancel button or terminates the window using the x button on the top tight corner.
I am not sure if I need to write a method or there is already a method that gets called.
How would I go about doing this?
I am not sure if I need to write a method or there is already a method that gets called.
How would I go about doing this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To close with the x at corner
you need to implement WindowListener (add implemnets WindowListener in the declaraion of the calss)
and add these methods to your code in your dilaog:
you need to implement WindowListener (add implemnets WindowListener in the declaraion of the calss)
and add these methods to your code in your dilaog:
public void windowClosing(WindowEvent evt) {
this.dispose();
}
public void windowOpened(WindowEvent evt){}
public void windowIconified(WindowEvent evt){}
public void windowDeiconified(WindowEvent evt){}
public void windowActivated(WindowEvent evt){}
public void windowDeactivated(WindowEvent evt){}
public void windowClosed(WindowEvent evt){}
ASKER
Once again thanks for much for the quick response from both of you. I was able to take CEHJ suggestion and get that working. for_yan I love the example, but already completed.
:)
When the use hits cancel button you can just
call
this.dispose()
if you are handilng events inside your daailog