Java examples for 2D Graphics:Paint
Set Drawing Mode To XOR
import java.applet.Applet; import java.awt.Color; import java.awt.Graphics; public class Main { public void paint(Graphics g){ //setForeground(Color.RED); g.setXORMode(Color.GRAY); g.fillRect(10,10,50,50); g.fillRect(20,30,50,50); /*from ww w. j a va 2 s . co m*/ g.setPaintMode(); } }