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?

jkteaterAsked:
Who is Participating?
 
for_yanCommented:

When the use hits cancel button you can just
call

this.dispose()

if you are handilng events inside your daailog
0
 
for_yanCommented:
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:
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){}

Open in new window

0
 
jkteaterAuthor Commented:
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.
0
 
CEHJCommented:
:)
0
All Courses

From novice to tech pro — start learning today.