See tutorials on custom painting here: Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)

And here: Custom Painting - Tutorials - Static Void Games