Graphics Modes

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 ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.