Wrong approach. Never use getGraphics of a component in client code. This approach cannot and will not work consistently.

To get better help sooner, post a SSCCE *
* SSCCE : Java Glossary

db