I just wrote a tutorial on this: Animation - Static Void Games

The tutorial uses Processing, but the concepts are the same.

If you have a more specific question about a problem you're having,...