Friday, July 23, 2010

Moving face

Buzz It
import java.io.*;
import java.awt.*;
import java.applet.*;
/*<applet code="movingface" width=500 height=500>
</applet>
*/
public class movingface extends Applet implements Runnable
{
int x=5,y=5;
Thread t=null;
public void start()
{
t=new Thread(this);
t.start();
}
public void run()
{
for(int i=0;i<100;i++)
{
try
{
repaint();
Thread.sleep(200);
x=x+10;
y=y+10;
}
catch(InterruptedException e)
{
System.out.println(e);
}}
}
public void paint(Graphics g)
{
g.drawOval(40+x,40+y,120,150);
g.drawOval(57+x,75+y,36,20);
g.drawOval(110+x,75+y,30,20);
g.fillOval(68+x,81+y,10,10);
g.fillOval(121+x,81+y,10,10);
g.drawOval(85+x,100+x,30,30);
g.fillArc(60+x,125+x,80,40,180,180);
g.drawOval(25+x,92+x,15,30);
g.drawOval(160+x,92+x,15,30);
}
}
OUTPUT

0 comments:

Post a Comment