import java.applet.*;
import java.awt.*;
import java.awt.Graphics;
import javax.swing.*;
import java.awt.event.*;

public class ShiYan12_2 extends Applet implements ActionListener{
	AudioClip au;                         //
             JButton start=new JButton("");
             JButton stop=new JButton("ֹͣ");
             public void init(){
	  au=getAudioClip(getCodeBase(),"lz.au");//װļ
	  setLayout(new FlowLayout());//òֹ
	  start.addActionListener(this);//ע
	  stop.addActionListener(this);
	  add(start);//Ӱť
	  add(stop);
}
    public void actionPerformed(ActionEvent e){//¼
	  JButton b=(JButton)e.getSource();
	  if(b.equals(start)){
		au.loop();//ļ
		}
	  if(b.equals(stop)){
		au.stop();//ֹͣ
		}
	}
    public void destroy(){//Сʱ
	   au.stop();
    }
	public void paint(Graphics g){
		g.drawOval(100,60,180,180);//face
		g.fillOval(120,110,40,35);//left eye
		g.fillOval(220,110,40,35);//right eye
		g.fillOval(180,160,25,25);//nose
		g.setColor(Color.red);
		g.fillArc(166,190,50,30,180,180);//mouse
		g.fillArc(85,45,80,80,25,223);//left ear
		g.fillArc(215,45,80,80,-57,213);//right ear
		g.drawLine(156,230,96,340);//body
		g.drawLine(96,340,126,430);
		g.drawLine(236,230,296,340);
		g.drawLine(296,340,256,430);
		g.drawLine(126,430,256,430);
		g.fillOval(80,260,50,50);//arm
		g.fillOval(260,260,50,50);
		g.fillOval(100,410,50,50);//leg
		g.fillOval(230,410,50,50);
	}
}
