• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Double Buffered Swings

 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
reply
    Bookmark Topic Watch Topic
  • New Topic