Have a look at this tutorial for examples: Trail: 2D Graphics (The Java™ Tutorials)