Hi,
I have a very simple / stupid question,
Does swing repaint component not visible on screen ?
By not visible I means that component is set to visible but not paint
on screen
(for example, in a scrollPane, if some component are not visible are
they repaint...)
Thanks
Steve W. Jackson - 07 Dec 2007 15:38 GMT
In article
<dcb0a51d-0d17-43f3-a83a-4453cec5fea0@b40g2000prf.googlegroups.com>,
> Hi,
>
[quoted text clipped - 7 lines]
>
> Thanks
If you look closely at how a scroll pane works, you'll find that it has
a "viewport" through which its contents can be seen. Only the portion
of its contents that are within the area the viewport currently displays
will actually get painted. This is probably greatly oversimplified, as
double buffering or other things may cause some off-screen rendering to
ensure a fairly quick display should you scroll, but that's the gist of
it.

Signature
Steve W. Jackson
Montgomery, Alabama
A. Bolmarcich - 07 Dec 2007 17:09 GMT
> Hi,
>
[quoted text clipped - 5 lines]
> (for example, in a scrollPane, if some component are not visible are
> they repaint...)
According to
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Container.html#paint(java.awt.G
raphics)
"If a child component is entirely clipped by the current clipping
setting in g, paint() will not be forwarded to that child."
When painting directly to the screen, the paint method of a component
is not invoked if no part of the component is on the screen. As Steve
W. Jackson mentioned in another follow-up, off-screen rendering, such as
used by double buffering, complicates the answer, and the paint method
of a component may be invoked to pain to an off-screen buffer even though
no part of the component is on the screen.
According to
http://java.sun.com/products/jfc/tsc/articles/painting/#swing_summary
"Components which render complex output should make smart use of the
clip rectangle to narrow the drawing operations to those which
intersect with the clip area."
Where "smart use" means the paintComponent(Graphics g) code invokes
only draw methods on the Graphics parameter that will draw inside the
clip area of the Graphics. Draw methods that would only draw outside
the clip area are not invoked, reducing the amount of drawing.