Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!novia!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "Michael Rauscher" Subject: Re: Get frame reference Message-ID: X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui In-Reply-To: References: Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 29 Date: Wed, 27 Apr 2011 15:31:18 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303918278 96.60.20.240 (Wed, 27 Apr 2011 10:31:18 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:31:18 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:1089 To: comp.lang.java.gui Rogan Dawes wrote: > Andrew Thompson wrote: >> Component has a getParent() method. >> Keep calling that in a loop till the >> call returns a null component, and you >> should have the root component. >> > And SwingUtilities has a method that will do this for you: No. windowForComponent just calls getWindowAncestor. And getWindowAncestor returns the *first* Window ancestor of a given component. Andrew's method returns the *last* Component ancestor (which might be a Window). To get the root Window (or root Applet) of a component, SwingUtilities#getRoot may be used. To get the root Component of a component use Andrew's method. To get a component's window use windowForComponent (or getWindowAncestor). Of course, there might be additional predefined methods - who knows? ;) Bye Michael --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24