With setVisible( true ), if the Component is not already marked visible, setVisible calls invalidate() which invalidates the Container’s layout and the chain of parents since there is now less screen real estate in the Container and the positions of the siblings must be adjusted to squeeze in this new Component.
Further, setVisible will schedule a repaint if the visibility status actually changed. However, it won’t schedule the Container.validate() automatically. That is up to you to do after all your visibility changes to the Components are done.
show() unhides a component by marking it as visible, allowing it to be painted again on the next painting cycle. show is deprecated. With Java version 1.1 or later you are supposed to use setVisible( true);
A Component is considered visible if in on any repainting cycle, it should be repainted. It might not actually be visible on the screen right now because it is occluded, or because CardLayout is not currently displaying the panel in which the component lives.
How are invisible elements treated?
setVisible has no effect on the visibily flags of the children. Unlike some GUI (Graphic User Interface) programming systems, when you parent.setVisible( true ) you don’t disturb any of the children’s visibility flags and the hidden children will stay hidden, even when you again reveal the parent.
Unlike ordinary Components, Windows, Frames and JFrames conveniently start out life automatically with setVisible( false ). Traditionally you do the validate() and setVisible( true ) in the code that calls the Frame’s constructor not in the Frame’s constructor or addNotify method.
hide() make temporarily invisible. hide is deprecated. With Java version 1.1 or later you are supposed to use setVisible( false); instead. hide is also used to describe what one window does to another when it is painted over top of it.
This page is posted |
http://mindprod.com/jgloss/setvisible.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\setvisible.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[3.129.216.15] |
| |
Feedback |
You are visitor number | |