Article View: borland.public.jbuilder.java.swing
Article #8697Re: How to cancel termination of application?
From: John P. McGrath
Date: Fri, 21 Jul 2000 00:00
Date: Fri, 21 Jul 2000 00:00
35 lines
1937 bytes
1937 bytes
On Thu, 20 Jul 2000 16:00:09 +0300, X_Aki Nieminen_X wrote: > Now I am having problems with the following feature. > I want to cancel termination of application in > "windowclosing" event, but it does not work as > expected. > > If I select "yes" from the confirmdialog, then > application is terminated (windowclosing and > windowclosed handlers are called). > > If I select "no" from the confirmdialog, then > application keeps running BUT still main window > dissapear from the screen. Main window is a subclass > of JFrame. > > How to cancel terminaton and still keep main window visible on screen? JFrame implements a default response to the close button. You can tell it how to behave with the setDefaultCloseOperation() method. The valid arguments are: DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, and EXIT_ON_CLOSE. The default is HIDE_ON_CLOSE, which explains the behavior you are seeing. The first three work with JDK 1.2, and the last one (EXIT_ON_CLOSE) was (sort of) added with JDK 1.3. The implementation of EXIT_ON_CLOSE was actually added in JDK 1.2, but the constant was not defined until JDK 1.3 (pretty strange, huh?). That means you can compile a program that uses this value only with JDK 1.3, but it will run under JDK 1.2. You can also specify the value 3 and then the program will compile under 1.2. -- Regards, John McGrath
Technical Details
Message-ID:
<MPG.13e1cbfac6f34223989a56@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<397576c9@dnews> <MPG.13e0477786e74b8b989a4e@forums.borland.com> <3976f4a9@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: How to cancel termination of application? Date: 2000/07/21 Message-ID: <MPG.13e1cbfac6f34223989a56@forums.borland.com> X-Deja-AN: 648992427 References: <397576c9@dnews> <MPG.13e0477786e74b8b989a4e@forums.borland.com> <3976f4a9@dnews> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing