Wednesday, August 29, 2012

SWT Canvas DoubleBuffering to prevent flickering

There are already some examples of how to prevent flicker when drawing to an SWT Canvas.

Unfortunately, some of the examples, like this one:

http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/DoubleBuffer.htm

just didn't work for me when I tried it out.

Researching a bit more on the internet got me the real nice and easy solution, which was to build the Canvas using the style SWT.DOUBLE_BUFFERED.

Basically, use:

new Canvas( parent, SWT.DOUBLE_BUFFERED);

and you should be good to go.

It's just one of those things that makes life so much easier...

No comments:

Post a Comment