Article View: borland.public.jbuilder.java.swing
Article #11931Re: Window closing
From: Paul Furbacher
Date: Mon, 15 Mar 1999 00:00
Date: Mon, 15 Mar 1999 00:00
27 lines
1527 bytes
1527 bytes
Leo Cohen wrote:
> I have two non modal JDialog windows on the screen. Each has a window
> closer in its title bar. When one of the windows, A, has focus, I go
> directly to window B's closer with the mouse and press it. This causes a
> windows closing event for A (a breakpoint shows that) which is what I
> want. However, the program then closes B (skipping the windows closing
> event; i.e., no breakpoint).
>
> Is there any way to intercept the closing of B so as to prevent it?
Each window's windowClosing event handler should ask which window
is the source of the event. If not "this" window, ignore the event
by not hiding the window.
It should go something like this:
public void windowClosing(WindowEvent e) {
if ( e.getSource() == this )
this.setVisible(false);
}
[I don't have the PC on so the above is from memory, but it's
close to what you want.]
Paul Furbacher
Technical Details
Message-ID:
<36EDD25E.E0EF0EE4@bilbo.bio.purdue.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<36ED5340.59DD4EA5@cs.virginia.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,9db34235e6d2af09 X-Google-Attributes: gid111d45,public From: Paul Furbacher <pf@bilbo.bio.purdue.edu> Subject: Re: Window closing Date: 1999/03/15 Message-ID: <36EDD25E.E0EF0EE4@bilbo.bio.purdue.edu> X-Deja-AN: 455485517 Content-Transfer-Encoding: 7bit References: <36ED5340.59DD4EA5@cs.virginia.edu> To: Leo Cohen <lcohen@cs.virginia.edu> Content-Type: text/plain; charset=us-ascii Organization: Reverse Alchemy, Inc. Mime-Version: 1.0 Reply-To: pf@bilbo.bio.purdue.edu Newsgroups: borland.public.jbuilder.java.swing