This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why a window can not add to a container?

 
laura_zpf
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
The answer is c),e).
why the window can not add to the container? and by the way, the container aslo can not add to the container?
 
Ramesh Donnipadu
Ranch Hand
Posts: 100
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A window is a top level class and cannot be incorporated into other components. So you cannot add window to a container.
You can add one container to other in general. However the question is adding a container to a container which has the former container. Getting confused?
Suppose you have container A which has several buttons, textfields, labels etc. You can add other containers (say B, C etc.) to A. Suppose A itself is added to another container Z. Then you cannot add Z to A.
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That�s an interesting question!
I remember reading Tony Alicea explanation where he said that although add method, defined in Container class has signature add(Component comp), attempt to add a window will cause IllegalArgumentException.
I looked at add() method code. All overloaded versions of it merely call addImpl method, whose comments said:

/* Check for correct arguments: index in bounds,
* comp cannot be one of this container's parents,
* and comp cannot be a window.
*/

here is part of addImpl code:

Interesting, that java API� description for add methods never mentioned that Window cannot be added to a container.
I believe that you can add Panel or Applet to a container.

[This message has been edited by Mapraputa Is (edited September 20, 2000).]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic