Java AWT Tutorials

adplus-dvertising
Working With Paint Mode Without Showing Pointer
Previous Home Next

In this example we are going to set paint mode. Paint mode determines how object are drawn in a window. By default ,new output to a window overwrites any pre existing context.

Example

//Working with paint mode
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*
<applet code="XORMode" width=300 height=200>
</applet>
*/
public class XORMode extends Applet{
public void paint(Graphics g){
g.setColor(Color.yellow);
g.drawLine(0,0,200,200);
g.setColor(Color.black);
g.fillRect(20,20,70,70);
g.setColor(Color.red);
g.drawLine(10,100,50,00);
g.setXORMode(Color.black);
g.setPaintMode();
}
}

Output of Example

Download Source Code

Previous Home Next