This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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.