I'm using the Animator class from the Timing Framework to perform a simple animation (moving a JPanel), roughly based on examples in Filthy Rich Clients
I've overridden timingEvent() as follows
public void timingEvent(float arg0) {
float fraction = this.animator.getTimingFraction();
fraction = Math.min(1.0f, fraction);
if (fraction >= 1.0f) {
this.mainGUI.initiateSwitchToMainScreenTransition();
} else if (fraction < 0.5f) {
this.translateY = (int) (MAX_Y * (2 * fraction));
repaint();
}
}
I've overriden paint() to use the value in translateY to move the panel down.
The animation itself works perfectly.
My problem is the call to initiateSwitchToMainScreenTransition(), which I want to be performed when the animation is complete. Whilst this works, there is a sizeable delay between the animation ending and the call firing (debugging has confirmed that the problem isn't the length of the time taken by initiateSwitchToMainScreenTransition() - the delay occurs before the call).
Is there a better way to achieve this, i.e. without the delay?