Solved

Closing / Terminating a dialog window

Posted on 2011-09-21
5
191 Views
Last Modified: 2012-08-13
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?

0
Comment
Question by:jkteater
  • 2
  • 2
5 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 36575520
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36575825

When the use hits cancel button you can just
call

this.dispose()

if you are handilng events inside your daailog
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36575852
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
 

Author Comment

by:jkteater
ID: 36575906
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 36576191
:)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now