Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1089

Re: Get frame reference

From "Michael Rauscher" <michael.rauscher@THRWHITE.remove-dii-this>
Subject Re: Get frame reference
Message-ID <esaa04$m4d$1@registered.motzarella.org> (permalink)
Newsgroups comp.lang.java.gui
References <es9jl8$2nt$1@wblv-ip-nnrp-1.saix.net>
Date 2011-04-27 15:31 +0000
Organization TDS.net

Show all headers | View raw


  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

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Find similar


Thread

Get frame reference "Tony B" <tony.b@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
  Re: Get frame reference "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
    Re: Get frame reference "Rogan Dawes" <rogan.dawes@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
      Re: Get frame reference "Tony B" <tony.b@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
      Re: Get frame reference "Michael Rauscher" <michael.rauscher@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000

csiph-web