The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2002



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


obtaining reference to JInternalFrame from sub-component

Posted by Dan Desch on January 14, 2002 at 4:52 PM

Greetings, I'm new to Java and this is my first post to this forum, so bear with me.

I am trying to implement a Multi Document Interface (MDI) using JInternalFrames (as prescribed). I have instances where I have JPanels loaded onto an internal frame and I need to obtain a reference to that parent internal frame within the context of my JPanel class. I've tried getParent (e.g. myJpanelClass.getParent()), but this does not return a reference to the JInternalFrame, but to a JPanel object. This doesn't make much sense to me--the parent of my JPanel is another JPanel? Or is this the content pane from the internal frame? The Java documentation is less than effusive on this subject.

I suppose I could work around this problem by passing a reference to the internal frame as a parameter in the constructor for my JPanel class, but this seems clumsy.

So, I guess I really have two concrete questions:

1. What is getParent() giving me, if not the internal frame?
2. If getParent() is not the right path to take, what is?

Dan Desch.


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us