恩同意我偶像的话..可以听了...
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
class Music
implements ActionListener{//extends Applet 随便要不要都可以
private AudioClip audioClips ;
private JButton jbtplay = new JButton("play");
private int currentIndex = 0;
public Frame f;
public void Load(){
f=new Frame("音乐播放器");
f.setBounds(160,60,360,300);
f.setLayout(new BorderLayout());
JPanel p = new JPanel();
p.add(jbtplay);
f.add(p,BorderLayout.NORTH);
//getContentPane().add(p,BorderLayout.CENTER);
f.setBackground(Color.white);//设置Frame背景色为白色
//显示框架窗口
f.pack();
f.setVisible(true);
try{
audioClips=JApplet.newAudioClip(Class.forName("Music").getResource("481.wav"));
}catch(ClassNotFoundException e){}
jbtplay.addActionListener(this);
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);}});
}
public void actionPerformed(ActionEvent e){
audioClips.play();
System.out.println("####");
}
public static void main(String[] args ){
Music m=new Music();
m.Load();
}
}
SHEET!