How to do animation using swing and clojure ?

Posted by Humberto Pinheiro on Stack Overflow See other posts from Stack Overflow or by Humberto Pinheiro
Published on 2010-05-26T13:51:46Z Indexed on 2010/05/26 14:21 UTC
Read the original article Hit count: 256

Filed under:
|
|
|

I'm trying to animate a chess piece in a board. First I created a java.util.Timer object that "scheduleAtFixedRate" a TimerTask implemented as a proxy function. So I kept a record of the piece to move (piece-moving-record) and when it's apropriate (when the user move the piece using the mouse) the TimerTask proxy function should be test if the record is not nil and execute the piece-moving function. The piece-moving function just updates the x and y coordinates of the piece, according to a vector pre-calculated. I put a add-watch on the piece-moving-record so when it changes it should repaint the board (canvas). The paint method tests if this piece-moving-record is not nil to paint it.

The problem is that the animation doesn't appear. The piece just jump to the destiny, without the movement between. There is some problem with the animation scheme ou there is a better way to do it?

© Stack Overflow or respective owner

Related posts about java

Related posts about swing