Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes how to use getParent() ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to use getParent() ?" Watch "how to use getParent() ?" New topic
Author

how to use getParent() ?

chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 188
Hi,

I created a class that extend JDialog , and initialize the constructer with jframe as the parent window.





How can I use getParent() in order to get all components from the jframe parent ?


Thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Container has some methods to query the components it has.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 188
can you please add example ?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10169
    
    8

Did you check out the Container API like Rob suggested?
Did you find any methods how to get components (wink, broad hint) for a given container?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 188
yes ,
I did check and I don't understand how should I retrieve the parent frame.

Thanks anyway
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10169
    
    8

angus young wrote:
I did check and I don't understand how should I retrieve the parent frame.


Looks like there is some confusion here. What exactly are you trying to do, because you initially said
How can I use getParent() in order to get all components from the jframe parent ?


So do you want to retrieve the parent or the components nested in a parent?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

To retrieve the parent, call getParent() until you find the one you need:
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> How can I use getParent() in order to get all components from the jframe parent ?

why would you want to? - you pass the parent as an argument to the dialog's constructor, so use that.


now the rest of the FindMenu() code can refer to parentFrame
 
 
subject: how to use getParent() ?
 
Similar Threads
Prevent JFrame from minimizing
How to access parent JFrame component from its Child frame
JDialog
change default logo
SWING - Changing java cup to my gif