🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #332

Re: stopping window close event

#332
From: Paul Furbacher [TeamB]
Date: Tue, 16 Aug 2005 13:55
41 lines
2306 bytes
dingfelder wrote:

> I am trying to make my application ignore clicks on the X in the
> top right.  I have read on the web that you do this via:
> 
> setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
> 
> Other posts have said you also do:
> 
> addWindowListener( new WindowAdapter() { public void
> windowClosing(WindowEvent e) { System.out.println("exit was
> pressed"); } });
> 
> When I do these both in my JFrame, the windowClosing event does
> indeed get called because I see the message, but then it goes ahead
> and exits.
> 
> How can I make it NOT exit?

I don't think you can intercept and cancel the window
closing event.  Perhaps all you can do is set the
frame to be visible again.  Annoying, but unless you
change the container to a dialog box, for which you
do get a chance to cancel an attempt to close, you
are stuck ... unless someone knows some other trick.


-- 


Paul Furbacher (TeamB)

   Save time, search the archives:
        http://info.borland.com/newsgroups/ngsearch.html

   Is it in Joi Ellis's Faq-O-Matic?
        http://www.visi.com/~gyles19/fom-serve/cache/1.html

   Finally, please send responses to the newsgroup only.
   That means, do not send email directly to me.
   Thank you.
Technical Details
Message-ID: <4301f032$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <43018137$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,18e74e2743c5a2cd
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 16 Aug 2005 09:55:06 -0400
From: "Paul Furbacher [TeamB]" <pfurbacher@mac.com>
Organization: Reverse Alchemy, Inc.
User-Agent: Mozilla Thunderbird 0.8 (Macintosh/20040913)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing
Subject: Re: stopping window close event
References: <43018137$1@newsgroups.borland.com>
In-Reply-To: <43018137$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 69.142.222.65
Message-ID: <4301f032$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1124200498 69.142.222.65 (16 Aug 2005 06:54:58 -0700)
Lines: 41
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail