I don't really know how to use javax.swing.timer in my application. My program animates a sprite moving across the screen to wherever you click, and it must look like it's traveling there. I used to use thread.sleep(), but that doesn't work anymore, so I've heard that I need to use javax.swing.timer. Here is my moveTo() method(I took the Thread.sleep() parts out):
I don't know how to insert the actionlistener. I have tried by myself but I can't seem to get it right. Btw, the moveTo method is called in a separate class, on the EDT.
lol Campbell.
i just wanted to mention that the timer can be started in the constructor. i had the run() method because i couldn't compute origin in my constructor. it seemed like a good place to start the timer.