Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Window

 
Gaia Nathan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic