-
Double Buffering
Hey guys,
I've seen all the chat on double buffering, yet having followed the guidelines my scribble application still flickers really badly. Here is the paint method:
Code:
@Override
public void paintControl(PaintEvent arg0)
{
Image bufferImage = new Image(s.getDisplay(), s.getBounds());
GC gcImage = new GC(bufferImage);
// Draw the background
gcImage.setBackground(arg0.gc.getBackground());
gcImage.fillRectangle(bufferImage.getBounds());
// draw the stack of points I have been collecting from mouse events
for (int i =0;i<(l.size()-1);i++)
{
gcImage.drawLine(l.elementAt(i).x, l.elementAt(i).y,l.elementAt(i+1).x,l.elementAt(i+1).y);
}
// draw the buffered image to the screen
arg0.gc.drawImage(bufferImage, 0, 0);
// Clean up
bufferImage.dispose();
}
Any ideas why?
-
sorted
Think I've sorted this, it seems the OS was redrawing the background when I was doing that too...so creating a shell with SWT.NO_BACKGROUND as a parameter in the constructor was the solution