html
php
c
linux
android
ruby-on-rails
mysql
visual-studio
eclipse
silverlight
flash
json
facebook
oracle
tsql
apache
php5
asp
api
dom
Thanks to comments by @Max I have found a solution to my own problem, creating an inner class inside my main Applet class that extends ActionListener.
public class AniTimer implements ActionListener { Element animating; PieceLoc blank; int orig_x; int orig_y; long timeStart; int delta; public AniTimer(Element e, PieceLoc pl) { animating = e; blank = pl; orig_x = animating.x; orig_y = animating.y; timeStart = System.currentTimeMillis(); } public void actionPerformed(ActionEvent evt) { int dx = (blank.x*piece-orig_x); int dy = (blank.y*piece-orig_y); int t = 200; delta = (int)(System.currentTimeMillis()-timeStart); if (delta>t) delta=t; animating.x = orig_x + dx*delta/t; animating.y = orig_y + dy*delta/t; repaint(); if (delta==t) { aniTimer.stop(); animating.updateCA(); board.checkCompleted(); } } }
Then when I want to start the animation all I do is make a new Timer with a new instance of my ActionListener class as the second argument and I can pass all the vital arguments relating to just this particular stint of animation to the constructor.
aniTimer = new Timer(20, new AniTimer(e, board.getBlankPl())); aniTimer.start();
Thanks Max, I'm starting to love Java now!