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.
|
|
available on the web at: |
http://mindprod.com/jgloss/setvisible.html |
optional Replicator mirror
|
J:\mindprod\jgloss\setvisible.html | |
![]() |
Please email your
feedback for publication,
letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear
wording, broken/redirected link reports, suggestions to improve this page or comments to
Roedy Green :
| |
| Blog | Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[107.21.186.38] |
|
| Feedback | You are visitor number 64,323. | |