java.awt.Graphics provides two graphics modes: paint and XOR. Paint mode is the default; graphical operations performed in paint mode simply overwrite existing graphics. XOR mode, on the other hand, allows graphical operations to be performed over existing graphics without disturbing the affected areas. Until Up until now, all of the rendering in this chapter has been done in paint mode, so we will concentrate on XOR mode in this section.
The documentation for Graphics.setXORMode(Color) describes XOR mode as follows:
When drawing operations are performed, pixels which are the current color are changed to the specified color, and vice versa.
Pixels that are of colors other than those two colors are changed in an unpredictable but ...