import java.awt.*;
import javax.swing.*;
// simple applete demonstrating changing colors in a loop
// using a variable called b to control the choice
// drawing centepede walking on gra
public class Applet3 extends JApplet
{
Thread t = new Thread();;
public void paint(Graphics g)
{
int a;
int b=0;
g.setColor(Color.green);
g.fillRect(1,300,500,200); // draw background
for(a=1;a<160;a=a+20)
{
if (b==1)
{
g.setColor(Color.blue);
b=2;
}
else
{
g.setColor(Color.black);
b=1;
}
g.fillOval(a,400,20,20);
g.setColor(Color.red);
g.fillRect(a+5,418,4,35); // draw legs
g.fillRect(a+10,418,4,35); // draw legs
try{t.sleep(200);} catch(Exception e){}
}
}
}