I wrote a class that represents an animated image. (Yes, I know, it's been done elsewhere; mine has extra features, blah blah blah...) The image is intended to be about as usable as any other JComponent; you can add it to a container as painlessly as a JButton.
The problem is in making it stop properly. When animating, it runs in its own Thread. (I should probably use the Timer thread instead, but that's a separate problem.) If the JFrame containing the animation is disposed of, the animation should stop; however, I don't know how it can tell that this has happened. I don't want to pass the JFrame to the animation object. It would violate the "painless" rule, and wouldn't handle the case where the animation is moved to a different JFrame. The animation can't go up the container hierarchy looking for a JFrame, since I often build interfaces from the leaf components up, and so it hasn't yet been assigned to a JFrame. I could go up the hierarchy when the animation is running, and then keep calling JFrame.isDisplayable(?), but that seems costly. Right now, it's up to the programmer to stop the animation when the frame closes. If the programmer forgets, the thread keeps running - Bad Thing. What's the "right" way to do this? All the animation examples I've found on the web don't address this. _______________________________________________ Advanced-swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/advanced-swing
