小弟新学java 代码问题希望各位大大看看谢谢啦
javase程序代码如下是个音乐播放程序
import java.applet.AudioClip;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Event;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.net.URL;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
//播放声音程序
public class AudioPlayDemo extends JFrame implements ActionListener,ItemListener{
boolean looping = false; //是否循环播放
String[] choics = {
"F X - Chocolate Love.wav",
"F X - Chu.wav",
"F X - Dangerous.wav",
"F X - Electric Shock.wav",
"F X - Hot Summer.wav",
"F X - Ice Cream.wav",
"F X - Jet.wav" //声音文件名数组
};
URL file1 = getClass().getResource(choics[0]); //声音文件1
URL file2 = getClass().getResource(choics[1]); //声音文件2
URL file3 = getClass().getResource(choics[2]); //声音文件3
URL file4 = getClass().getResource(choics[3]); //声音文件4
URL file5 = getClass().getResource(choics[4]); //声音文件5
URL file6 = getClass().getResource(choics[5]); //声音文件6
AudioClip sound1 = java.applet.Applet.newAudioClip(file1);
//声音剪辑对象1
AudioClip sound2 = java.applet.Applet.newAudioClip(file2);
//声音剪辑对象2
AudioClip sound3 = java.applet.Applet.newAudioClip(file3);
//声音剪辑对象3
AudioClip sound4 = java.applet.Applet.newAudioClip(file4);
//声音剪辑对象4
AudioClip sound5 = java.applet.Applet.newAudioClip(file5);
//声音剪辑对象5
AudioClip sound6 = java.applet.Applet.newAudioClip(file6);
//声音剪辑对象6
AudioClip chosenClip = sound1; //选择声音的剪辑对象
JComboBox jcbFiles = new JComboBox(choics); //文件选择组合框
JButton loopButton = new JButton("循环播放"); //循环播放按钮
JButton palyButton = new JButton("播放"); //播放按钮
JButton stopButton = new JButton("停止"); //停止按钮
JLabel status = new JLabel("选择播放文件"); //状态栏标签
JPanel controlPanel = new JPanel(); //控制面板用于包容按钮