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 / First Aid / February 2006

Tip: Looking for answers? Try searching our database.

Double Buffering - more detail

Thread view: 
dontspam@_dylan_.gov - 05 Feb 2006 08:36 GMT
Hi, I'm looking for some double-buffering help. I'm back with a different question than my previous one.

Within a derived Canvas class, PlotCanvas, I have declared:

Image offscreenImage;
Graphics offscreenGraphics;

What I originally had inside paint() was:

------------------------------

if(offscreenImage == null) {
  offscreenImage = createImage(this.getSize().width, this.getSize().height);
  offscreenGraphics = offscreenImage.getGraphics();
}

// Do lots of drawing to 'offscreenGraphics'

g.drawImage(offscreenImage,0,0,this);

------------------------------

This resulted in flickering. I did some debugging and realized that immediately upon entering paint(), the canvas was cleared. So

during all of that writing to 'offscreenGraphics', the Canvas wasn't showing the old image, and swapping at the last minute.

So, I took "lots of drawing to 'offscreenGraphics'" and put that into a function, pre_paint(), with a repaint() at the end of it, so

that all that was needed inside paint() was:

g.drawImage(offscreenImage, 0, 0, this);

I still had flickering. Any suggestions?

The code is online at:
http://www.angelfire.com/retro/there/lab73_exer2.zip

The interesting functions are in the PlotCanvas class: paint(), pre_paint(), maybe update(). The project was done in Eclipse.

Help is very much appreciated, TIA.
Roedy Green - 05 Feb 2006 12:36 GMT
>I still had flickering. Any suggestions?

see http://mindprod.com/jgloss/flicker.html for some generic help on
flicker.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Paul Bilnoski - 06 Feb 2006 15:26 GMT
> Hi, I'm looking for some double-buffering help. I'm back with a different question than my previous one.
>
> Within a derived Canvas class, PlotCanvas
[snip]

A JPanel internally supports double-buffering, so you might try using
that as your base if possible.
--Paul


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.