• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Do you always need setVisible?

 
Kourosh Keshavarzi
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you only need the setVisible when you don't have
a layout manager.
Same with setBounds and setSize.
Does the layout manager take care
of that stuff for you?
Do yo have to setBounds and setSize or one is enought?
What purpose does te method show() have.
do you use it instead of setvisible.
My book uses it in its code but doesn't have any kind
of definition or anything.
thanks is advance
Kourosh
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setVisible, setBounds and setSize are all methods inherited from the Component Class. They will get default settings if you don't set them (false for setVisible and 0,0 for setBounds).
I am not sure if setSize can replace setBounds.
If you are running an Applet the size can be set in the HTML.
show() is deprecated but also from component.
 
Subha Guhan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also it is required only for top level components like window, frames etc. for components like buttons,textfields etc it is not a requirement to specify it.
 
Kourosh Keshavarzi
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Cindy and Subha.
Koursh
 
Aparna Narayanan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
One more addition...
setBounds(int x,int y, int width, int height) is used for Moving as well as Resizing a component
setSize(int width, int height) is only for resizing the component
So, setSize cannot replace setBounds in some cases.
Aparna
 
Sudha Kris
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct me if I am wrong, but I think if you don't use a Window or a Frame. ie if you use an Applet you don't need to set it visible. I mean you don't have to do setVisible(true).
Sudha
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic