照着书打的一个简单的音乐播放器,可编译时告诉我api过时,麻烦大神们能看一看
import java.awt.*;import *;
import java.awt.event.*;
import *;
import java.applet.*;
class AudioClipWindow extends Frame
implements Runnable,ItemListener,ActionListener
{Thread thread;
Choice choice;
URL url;
AudioClip clip;
Button buttonPlay,buttonLoop,buttonStop;
String str;
AudioClipWindow(){
thread=new Thread(this);
choice=new Choice();
choice.add("hey jude.wav");
choice.add("hole(live).wav");
choice.addItemListener(this);
buttonPlay=new Button("play");
buttonLoop=new Button("loop");
buttonStop=new Button("stop");
buttonPlay.addActionListener(this);
buttonLoop.addActionListener(this);
buttonStop.addActionListener(this);
setLayout(new FlowLayout());
add(choice);
add(buttonPlay);
add(buttonLoop);
add(buttonStop);
setSize(350,120);
setVisible(true);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{System.exit(0);
}
});
validate();
}
public void itemStateChanged(ItemEvent e){
str=choice.getSelectedItem();
if(!(thread.isAlive())){
thread=new Thread(this);
}
try{
thread.start();
}
catch(Exception ee){
}
}
public void run(){
try{File file=new File(str);
url=file.toURL();
clip=Applet.newAudioClip(url);
}
catch(Exception e){
System.out.println(e);
}
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==buttonPlay){
clip.play();}
else if(e.getSource()==buttonLoop){
clip.loop();}
if(e.getSource()==buttonStop){
clip.stop();}
}
}
public class qq{
public static void main(String args[]){
AudioClipWindow win=new AudioClipWindow();
}
}
去SUN公司查了一下api都有啊,麻烦能抽空看一下