DEV Community


Discussion on: Why does my canvas implementation keep blinking?

oliverobenland profile image
Oliver Obenland

It’s a Long time since I used Java and implemented double buffering. I’m not sure if I am correct. But my first finding, which I think is not necessary: you create and dispose the graphics ctx of the buffer. Just use the one you created in the constructor. And I don’t think you should dispose the panels Graphics. Just try it and observe for memory

baenencalin profile image
Calin Baenen Author

Thanks for the tip. Though, when I tried this, the canvas didn't draw anything (it stayed white). Where previously, it displayed an image, then went to black (which is where the flickering started).

Forem Open with the Forem app