Never never never use getGraphics() of a Component. Recommended reading, in line with copeg's recommendation:
Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With...
Type: Posts; User: Darryl.Burke
Never never never use getGraphics() of a Component. Recommended reading, in line with copeg's recommendation:
Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With...
What have you tried? It's a two-liner to use that mode: set the color, then set the XOR color.
To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example...