File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Window" Watch "Window" New topic


Gaia Nathan
Ranch Hand

Joined: Aug 01, 2001
Posts: 62
Hi. This question is really bugging me. Here goes:
The Container methods add( Component comp ) and add( String name, Component comp ) will throw an IllegalArgumentException if comp is a:
a) button
b) list
c) window
d) textarea
e) container that contains this container
Given answer: c,e
What I don't understand is that why can't I add a window into a container. According to the Java spec., I quote,
"A window must have either a frame, dialog, or another window defined as its owner when it's constructed."
Doesn't this mean that it can be added to another container, say another window or frame? Is there a particular component which absolutely cannot be added to a container? Please help.

Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Gaia,
You might be getting confused with terminology here. Just because something is created with a parent doesn't mean that it is inside of it. The container methods are for adding components into the container. For example, a button cannot exist outside of its container, but a dialog sure can!
Constructing a window using a window parent is not the same thing as added a window into another window. The same thing goes for creating a window using a frame parent.
Gaia Nathan
Ranch Hand

Joined: Aug 01, 2001
Posts: 62
Thanks for your help.
Yeah, I was confused with the terminology...
Does this mean that I can add a window into a container (for example another window or frame)? Is there a particular component(a top-level container) which absolutely cannot be added to a container? What do you think the answer to that question should be? Do you agree with the answer? I think the answer should only be e.
Thanks again for your help.
I agree. Here's the link:
subject: Window
It's not a secret anymore!