/*========================Pragramme Design=============================*/(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)
/* @程序说明:使用AudioClip类控制播放的音乐文件 */
/* @程序目的:线程的运用 */
/* @Writen by :kanker007 */
/* @Date:2005-05-11 */
/*=====================================================================*/
/*---------------------------------------------------------------------*/
/* 代码区 */
/*---------------------------------------------------------------------*/
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import java.applet.AudioClip;
public class LX_Thread extends Applet implements ItemListener,ActionListener
{
AudioClip sound;
Choice c=new Choice();
Button play=new Button("播放");
Button loop=new Button("连续");
Button stop=new Button("停止");
public void init(){
c.add("t.wav"); c.add("y.wav"); c.add("yd.wav");
add(c);
c.addItemListener(this);
add(play);add(loop);add(stop);
play.addActionListener(this);
loop.addActionListener(this);
stop.addActionListener(this);
sound=getAudioClip(getCodeBase(),"t.wav");
sound.play();
}
public void itemStateChanged(ItemEvent e){
sound.play();
//sound=getAudioClip(getCodeBase(),c.getSelectedItem());//"WAV/"+
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==play) sound.play();
else if(e.getSource()==loop) sound.loop();
else if (e.getSource()==stop) sound.stop();
}