• Post Reply Bookmark Topic Watch Topic
  • New Topic

which the best way to add components  RSS feed

 
Sunil Babu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ALL,
I need your help .
The problem is i am totally confussed regarding this problem.How to add components to any component and the thing is the container to which iam adding should a colored one
so please guide me
bye
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best ( and only ) way to add components to a container is through the container's add() method.

Though, if you are having problems adding components to containers and having them show up like you wanted them, then you are having problems with layout managers instead. Read about layout managers here... also it might be a problem with setting the component's preferred size too small... most layout managers use a component's preferred size to allocate space to it.

Coloring containers can easily be done using the setBackground( Color ) method. If the color doesn't show up, try calling setOpaque( true ) in the container right after setting the background color. Most containers are non-opaque ( i.e. "clear" ) so that you can see the root container's color through them.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!