Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

Dialog Close Operations

Thread view: 
bwilde@gmail.com - 07 Apr 2006 20:41 GMT
Hello,

I have a problem with Java dialogs that I fear that there is no
solution for, but I'm hopeful that there's a way to do it.  Basically,
I would like to call a method when a dialog window is closed (via the
'x' in the top right corner).  As far as I can tell, the
setDefaultCloseOperation method has several pre-defined operations, but
none of them seem to let me call my own function.  Is there any way
that I could associate a function with the action of clicking on the
close button?

Thanks,
Ben
Daniel Dyer - 07 Apr 2006 19:52 GMT
> Hello,
>
[quoted text clipped - 6 lines]
> that I could associate a function with the action of clicking on the
> close button?

You need to add a WindowListener  
(http://java.sun.com/j2se/1.5.0/docs/api/java/awt/event/WindowListener.html)  
so that you can respond to the windowClosing or windowClosed event.

Dan.

Signature

Daniel Dyer
http://www.dandyer.co.uk

Vova Reznik - 07 Apr 2006 20:53 GMT
> Hello,
>
[quoted text clipped - 9 lines]
> Thanks,
> Ben

Read about java.awt.event.WindowListener.
java.awt.Window (any Dialog is its sub) has method
public void addWindowListener(WindowListener l)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.