Results 1 to 2 of 2
- 04-21-2014, 07:02 PM #1
Member
- Join Date
- Apr 2014
- Posts
- 4
- Rep Power
- 0
Question about drawing animations in Java (SWT)
Hello, 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() it seems like program firstly erases everything that has been drawn and then draws again.
My program draws about 1000 of rectangles per time step so animation doesn't looks smooth - it blinks all the time and I can't avoid drawing that many rectangles.
Is there a way to make it look smoother (for example to paint new objects over old ones, without erasing them)?
I won't paste code, it's rather large.
Can you help me please?
- 04-22-2014, 05:28 PM #2
Member
- Join Date
- Apr 2014
- Posts
- 4
- Rep Power
- 0
Re: Question about drawing animations in Java (SWT)
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:
Java Code:Canvas myCanvas = new Canvas (parentComposite, SWT.DOUBLE_BUFFERED);
Similar Threads
-
Two-dimensional animations of Bubble Sort
By kkhat in forum AWT / SwingReplies: 1Last Post: 03-30-2013, 04:51 AM -
animations with java?
By shujisan87 in forum New To JavaReplies: 3Last Post: 09-13-2011, 04:09 PM -
Animations not refreshing
By zshaw in forum New To JavaReplies: 1Last Post: 12-26-2010, 12:05 AM -
Graphics/animations etc. Where to begin?
By Mattedatten in forum New To JavaReplies: 2Last Post: 03-16-2010, 05:51 PM -
SWT Animations Example
By Java Tip in forum SWT TipsReplies: 0Last Post: 06-28-2008, 09:23 PM
Bookmarks