File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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: 190
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: 19697
    
  20

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: 190
can you please add example ?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10426
    
    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: 190
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: 10426
    
    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: 19697
    
  20

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
 
jQuery in Action, 2nd edition
 
subject: how to use getParent() ?