import java.applet.*;
import java.awt.*;
import java.lang.*;
import java.math.*;
import java.awt.Color;
/*<applet code="face" height=578 width=678></applet>
*/
public class face extends Applet implements Runnable
{
int i=0,j=0,p=1;
Thread t;
public void init()
{
t=new Thread(this);
t.start();
}
public void run()
{
int sec=0;
try
{
while(true)
{
repaint();
sec+=1;
t.sleep(100);
}
}catch(Exception e)
{
System.out.println(e);
}
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
Dimension d=this.getSize();
double x=Math.random()*d.width;
double y=Math.random()*d.height;
setBackground(Color.black);
g.setColor(Color.yellow);
g.fillOval(118,118,500,400);
g.setColor(Color.white);
g.fillOval(219,158,90,90);
g.fillOval(419,158,90,90);
g.fillOval(319,258,80,150);
g.setColor(Color.red);
g.fillArc(219,418,300,50,180,180);
g.setColor(Color.black);
g.fillOval(219+j*p,188,30,30);
g.fillOval(479-j*p,188,30,30);
if(i==0)
{
j=j+10;
if(j==60)
{
i=1;
}
}
else
{
j=j-10;
if(j<=0)
{
i=0;
}
}
}
}
import java.awt.*;
import java.lang.*;
import java.math.*;
import java.awt.Color;
/*<applet code="face" height=578 width=678></applet>
*/
public class face extends Applet implements Runnable
{
int i=0,j=0,p=1;
Thread t;
public void init()
{
t=new Thread(this);
t.start();
}
public void run()
{
int sec=0;
try
{
while(true)
{
repaint();
sec+=1;
t.sleep(100);
}
}catch(Exception e)
{
System.out.println(e);
}
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
Dimension d=this.getSize();
double x=Math.random()*d.width;
double y=Math.random()*d.height;
setBackground(Color.black);
g.setColor(Color.yellow);
g.fillOval(118,118,500,400);
g.setColor(Color.white);
g.fillOval(219,158,90,90);
g.fillOval(419,158,90,90);
g.fillOval(319,258,80,150);
g.setColor(Color.red);
g.fillArc(219,418,300,50,180,180);
g.setColor(Color.black);
g.fillOval(219+j*p,188,30,30);
g.fillOval(479-j*p,188,30,30);
if(i==0)
{
j=j+10;
if(j==60)
{
i=1;
}
}
else
{
j=j-10;
if(j<=0)
{
i=0;
}
}
}
}
Comments