Like some other people have said, I'd still try to do this in your
paint(Graphics g) method. paint automatically gets called when the
window gets resized or programs are switched between. If you really
don't want to do it in the paint method, then in your drawGraphic()
method don't use any arguments, but instead make the first line
Graphics g=getGraphics();
This will make it so g draws to the right place. I hope this helps.