Article View: borland.public.jbuilder.java.language
Article #19921Re: Frame/Window
From: Mark Hunter
Date: Tue, 25 Nov 1997 00:00
Date: Tue, 25 Nov 1997 00:00
35 lines
2228 bytes
2228 bytes
Gary McGath wrote: > I don't think that's what he was asking. Windows aren't linked by getParent(). > Actually, I think Windows *are* linked by getParent(). In fact, I was about to leave a message about that. I've got a situation where a mouse click on a "Close" button needs to do a dispose() on the containing window. But in a nested-panel layout, getParent() just returns the next panel up, and so on. So I wrote a loop to call getParent() until the result came back null. Then I knew the last non-null result was the window itself. Worked great, until... I put the "Close" button in a Dialog that had been called by a Frame. The loop went up through the nested panels, right through the Dialog, and found the Frame. So the "Close" button ended up closing the Frame, which was NOT what I had in mind. By the way, this Close button is in a bean - that's why I can't explicitly use the parent window instance name. I don't know the name, at design time. Anyway, now I've got to alter my loop to stop at the first Window that it finds. And I need to ask an elementary question: If I have an instance of Container, which is what getParent() returns, how can I tell if that object is a Window or not? I tried casting it to Window and trapping ClassCastException, but I get the exception every single time, even when I know I'm actually dealing with a Window. Is there some cleaner way to do it? Thanks, Mark Hunter
Technical Details
Message-ID:
<347B8824.429C@dpsla.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<347440C3.D0B76A6B@oop.com> <3475E14E.AE4B0525@wli.net> <gmcgath-ya02408000R2111972049260001@news.ma.ultranet.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10a146,753c9b5de73c4539 X-Google-Attributes: gid10a146,public X-Google-Thread: 10fd6d,753c9b5de73c4539 X-Google-Attributes: gid10fd6d,public X-Google-Thread: fecd1,753c9b5de73c4539 X-Google-Attributes: gidfecd1,public X-Google-Thread: f74b3,753c9b5de73c4539 X-Google-Attributes: gidf74b3,public From: Mark Hunter <mhunter@dpsla.com> Subject: Re: Frame/Window Date: 1997/11/25 Message-ID: <347B8824.429C@dpsla.com> X-Deja-AN: 292713071 References: <347440C3.D0B76A6B@oop.com> <3475E14E.AE4B0525@wli.net> <gmcgath-ya02408000R2111972049260001@news.ma.ultranet.com> Organization: None Newsgroups: borland.public.jbuilder.java.language,comp.lang.java.gui,comp.lang.java.programmer,comp.lang.java.api