wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Double Buffered Swings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Double Buffered Swings" Watch "Double Buffered Swings" New topic
Author

Double Buffered Swings

Aaron Roberts
Ranch Hand

Joined: Sep 10, 2002
Posts: 174
I have a custom swing component which lets you paint on it and stamp. I am getting flickering though.

The user selects a stamp and can move it ontop of the existing drawing. When they want to paste the stamp down, then click. I keep two images, a buffer where the stamp has not been placed, and the current components image. As the stamp moves, I have to redraw what was under it from the original image. The problem is that you can see a flicker when a portion of the stamp imagery overlaps the old location.

Here's a quick snippet -


The g2d is the graphics context passed into the paintComponent() method. the backBuffer is an image which contains the original drawing. The isDoubleBuffered() method returns true on the object. Is there a way to avoid the flicker without making a third image to draw onto the screen in one pass?

I know there are buffer strategies, but that seems overkill for what I have.

Regards,
Aaron R>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Double Buffered Swings
 
Similar Threads
Increasing Speed
Flickering of Canvas
How to print user input on certificate in java
Stamping an Image
Plot zooming and double buffering