Article View: borland.public.jbuilder.java.swing
Article #8775Re: Destroying modal JDialog when clicked "OK", "Sys menu's Close", "title bar's X icon"
From: John P. McGrath
Date: Thu, 20 Jul 2000 00:00
Date: Thu, 20 Jul 2000 00:00
39 lines
2031 bytes
2031 bytes
On Wed, 19 Jul 2000 12:50:49 +0300, X_Aki Nieminen_X wrote: > If I call "this.dispose()" inside button handler, then > "windowClosing" event handler is never called, but only > "windowClosed" one. > > Finally, I created explicitly a new WindowEvent and > dispatch it to dialog instance. See my code below with > dispatching code. > > Is it legal to do it this way in Java to handle window > close operation, can I dispatch window message without > any side effects? Is there some better and efficient > way to this? I think you got it right. The windowClosing() event is poorly named, which is the source of much confusion. It is sent by the operating system to request that the window be closed. This occurs on Windows when you press the close [x] button, choose "Close" from the system menu, or press Alt+F4. Other operating systems have their own ways to send the event. The windowClosing() event does not actually close the window -- it is your dispose() call that closes it. If you want, you can ignore the event, and then the close button will do nothing. Since you call dispose(), the window is closed. The operating system then notifies your program that the window has been closed, and Java lets your code know by sending the windowClosed() event. If the AWT designers had thought about it a little more, they would have used a name like windowCloseRequest() rather than windowClosing(). This would have avoided a lot of confusion. -- Regards, John McGrath
Technical Details
Message-ID:
<MPG.13e0477786e74b8b989a4e@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<397576c9@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,1dadf17715fc8d0f X-Google-Attributes: gid111d45,public From: John P. McGrath <JPMcGrath@fast.net> Subject: Re: Destroying modal JDialog when clicked "OK", "Sys menu's Close", "title bar's X icon" Date: 2000/07/20 Message-ID: <MPG.13e0477786e74b8b989a4e@forums.borland.com> X-Deja-AN: 648481276 References: <397576c9@dnews> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing