The demo
applets that come with the JDK are mostly animations, so if you simply need to see how you might create an animation, then those are as good a place to start as any.
But you seem to be asking something else -- how to start an animation based on some event? That of course depends on how you're doing the animation, but in general, just write code which, when the event occurs, creates and starts a
Thread that runs the animation loop. If you need more details than that, then I think you'd have to ask a more specific question.