// the setXORMode command allows you to achieve animation on a specific
// object
// without the system redrawing the entire screen -- the repaint() command used
// in Applet4
// will redraw the entire screen each time it is executed (lmore flicker )
// in the output)
import java.awt.*;
import javax.swing.*;
public class Applet13 extends JApplet
{
Thread t = new Thread();;
int a;
public void paint(Graphics g)
{
g.setColor(Color.blue);
g.setXORMode(Color.white);
for(a=1;a<400;a=a+1)
{
g.fillOval(a,a,10+a,10+a); // draw an image
try{t.sleep(45);} catch(Exception e){} // pause long enough to see the image
g.fillOval(a,a,10+a,10+a); // draw same image again
// because of the setZORMode
// command the pixels of the same
// color and position will cancel
// each other and the white (background)
// is what appears -- hense the image disappears
}
}
}