Results 1 to 2 of 2
  1. #1
    instop is offline Member
    Join Date
    Apr 2014
    Posts
    4
    Rep Power
    0

    Default 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?

  2. #2
    instop is offline Member
    Join Date
    Apr 2014
    Posts
    4
    Rep Power
    0

    Default 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);
    Thanks to BenG

Similar Threads

  1. Two-dimensional animations of Bubble Sort
    By kkhat in forum AWT / Swing
    Replies: 1
    Last Post: 03-30-2013, 05:51 AM
  2. animations with java?
    By shujisan87 in forum New To Java
    Replies: 3
    Last Post: 09-13-2011, 05:09 PM
  3. Animations not refreshing
    By zshaw in forum New To Java
    Replies: 1
    Last Post: 12-26-2010, 01:05 AM
  4. Graphics/animations etc. Where to begin?
    By Mattedatten in forum New To Java
    Replies: 2
    Last Post: 03-16-2010, 06:51 PM
  5. SWT Animations Example
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 06-28-2008, 10:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •