Frequently when I call getGraphics() it returns null, even if I set the xxx.getGraphics(); xxx to be visible (as a Google search shows...)
But this doesn\'t work, a
Don't use getGraphics(). Any painting you do will be temporary and will be lost the next time Swing determines a component needs to be repainted.
Instead override the paintComponent() method of a JComponent or JPanel to do your custom painting. See Custom Painting for more details and examples.
paintComponent()