import java.awt.*;
import java.applet.*;
import java.util.*;
public class Applet1 extends Applet implements Runnable
{
AudioClip audioClip;
Thread ShapeThread=null;
Random RandomNumber=new Randow();
Color ImageColor;
public void init()
{
audioClip=getAudioClip(getCodeBase(),"吉祥三宝靖远.AU");
}
public void start()
{
if(ShapeThread==null)
{
ShapeThread=newThread(this);
ShapeThread.start();
}
}
public void run()
{
while(true)
{
switch(RandomNumber.nextlnt()%5)
{
case 0: ImageColor=Color.black;
break;
case 1: ImageColor=Color.blue;
break;
case 2: ImageColor=Color.cyan;
break;
case 3: ImageColor=Color.magenta;
break;
case 4: ImageColor=Color.orange;
break;
default: ImageColor=Color.red;
}
try
{
ShapeThread.sleep(300);
}
catch(InterruptedException e)
{
//忽略异常
}
repaint();
}
}
public void paint(Graphics g)
{
g.setColor(ImageColor);
audioClip.play();
switch(RandomNumber.nextlnt()%2)
{
case 0: g.fillRect(25,25,200,200);
break;
default: g.fillOval(25,25,200,200);
break;
}
}
}