Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2007

Tip: Looking for answers? Try searching our database.

Does swing repaint "hidden object"

Thread view: 
daf - 07 Dec 2007 14:18 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.