The Graphics
object is created by the paint sub system.
You should never be calling paintComponent
yourself and should simply allow the paint system deal with it. Even if you wanted to capture or print the component using your Graphics
context (from something like BufferedImage), you should be using print
or printAll
Take a look at Painting in AWT and Swing