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)