Solved

Closing / Terminating a dialog window

Posted on 2011-09-21
5
195 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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 “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

789 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