Solved

Closing / Terminating a dialog window

Posted on 2011-09-21
5
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

726 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