This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Window" Watch "Window" New topic
Author

Window

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.
Regards,
Manfred.
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: http://aspose.com/file-tools
 
subject: Window
 
Similar Threads
add method
why a window can not add to a container?
one question about container
When component class add method will throws an IllegalArguemnt Exception?
AWT qustion