What is "code to draw animation" short for? If that's where you've placed the actual animation loop, then the problem is that you'lll be blocking the event
thread, which is what actually repaints the screen; never do any long-running processing on the event thread! Instead, you have to create a new thread dedicated to running your animation.
The JDK demos include a number of animation
applets; look there for examples.