Question

i've got a question about drawing animations in Java (SWT). I try to draw an animation of some process. When i use canvas.redraw() program firstly erases everything that has been drawn and then draws again. My program draws about 1000 of rectangles per time step (this big quantity is necessary) so animation doesn't looks smooth - it blinks all the time. Is there a way to make it look smoother, for example to paint new objects over old ones, without erasing them (that would look better anyway)?

Était-ce utile?

La solution

The solution for flickering when doing custom painting is to use double buffering. The SWT Canvas object has built-in double-buffering, use it by adding the flag to the styles in the constructor:

Canvas myCanvas = new Canvas (parentComposite, SWT.DOUBLE_BUFFERED);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top