import java.applet.*;
import java.awt.*;
/*<applet code=animation
height=600 width=800></applet>*/
public class animation extends Applet
implements Runnable
{
int x=0;
Thread t=new Thread(this);
boolean b=false;
public void init()
{
}
public void start()
{
if(t.isAlive())
t.resume();
else
{
showStatus("thread is beaing
started");
t.start();
b=true;}
}
public void stop()
{
showStatus("threas is being
suspended");
t.suspend();
}
public void run()
{
while(true)
{
if(x==200)
x=0;
repaint();
}
}
public void paint(Graphics g)
{
if(b) {
g.setColor(Color.red);
g.fillOval(x,130,50,50);
g.setColor(Color.black);
g.fillOval(x+8,140,10,15);
g.drawArc(x+8,135,10,10,0,180);
g.fillOval(x+26,140,10,15);
g.drawArc(x+26,135,10,100,0,180);
g.drawArc(x+10,150,25,20,0,-180);
g.setColor(Color.white);
g.fillOval(x+10,144,5,5);
g.fillOval(x+28,144,5,5);
x++;
}}
public void destroy()
{
showStatus("the thread is being
destroyed");
t.stop();}}
కామెంట్లు లేవు:
కామెంట్ను పోస్ట్ చేయండి