• Post Reply Bookmark Topic Watch Topic
  • New Topic

Incremental Painting on lightweight Components

 
Landon Blake
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was reading an article on AWT and Swing. It indicated that incremental painting should not be used on lightweight components. Is this because lightweight components are usually to simple to require incremental painting, or is there another reason?
Thanks,
Landon
[ March 02, 2004: Message edited by: Landon Blake ]
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you are talking about Painting in AWT and Swing
Maybe some things have changed since the release of the article. For instance, literally: It's worth noting that the default implementation of Container.update() does not use recursion to invoke update() or paint() on lightweight descendents. However the API for Container.update says Updates the container. This forwards the update to any lightweight components that are children of this container.
More on that: The system-triggered paint request originates from the lightweight framework (i.e., the lightweight is resized), which results in a call to update(), which by default is forwarded to paint() .
However I cannot see that JButton.update is called as consequence of any resizing, hiding etc. of the frame in the following example.

We can check that update is neither invoked when repaint is called by pressing the repaint button.
I also tried a similar program in AWT version.

Now each time repaint is pressed update is called.
---------------------------------------------------------------------
Incremental painting in AWT relies on overriding update. The reason given in the article in order not to use incremental update for lightweight components is that update could be called as a consequence of system-triggered painting events; such as resizing, hiding etc. This would wreak havoc if an overriding update is supposed to be called only through repaint by the program.
Anyway it seems that for lightweight components update is not called by repaint.Just another reason to avoid incremental rendering in Swing.
Swing components were gifted with own optimizations like being doubled buffered by default. They do not need incremental rendering IMHO.
[ March 03, 2004: Message edited by: Jose Botella ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!