1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
/* Set Drawing Mode To XOR Example This java example shows how to set drawing mode to XOR instead of overwrite mode using setXORMode method of Graphics class. */ import java.applet.Applet; import java.awt.Color; import java.awt.Graphics; /* <applet code="SetXORPaintModeExample" width=200 height=200> </applet> */ public class SetXORPaintModeExample extends Applet{ public void paint(Graphics g){ /* * usually, the new drwaing objects overwrites the previously * drawn objects. Setting drwaing mode to XOR mode makes sure * that the existing contents will always be displayed and will * be XORed with the new objects. * * To set mode to XOR mode, use * void setXORMode(Color c) * method of Graphics class. */ //setForeground(Color.RED); g.setXORMode(Color.GRAY); g.fillRect(10,10,50,50); g.fillRect(20,30,50,50); /* * To set overwrite mode, use * void setPaintMode() * method of Graphics class. */ g.setPaintMode(); } } |
Example Output
Add Comment