/** * Plays the animation once. * * @param forward whether the animation should be played forward. */ private void playOnce(boolean forward) throws InterruptedException { int n = animation.getFrameCount(); for (int i = 0; i < n; i++) { int frame = forward ? i : n - i - 1; animation.showFrame(frame); if (Thread.interrupted()) { throw new InterruptedException("Play job interrupted."); } Thread.sleep(animation.getFrameDisplayTime(frame)); } }