6
69662929
Unregistered / Unconfirmed
GUEST, unregistred user!
import java.awt.*;
import java.applet.AudioClip;
import java.awt.event.*;
import javax.swing.*;
public class sound extends JFrame implements ActionListener{
AudioClip clip1;
AudioClip clip2;
JButton but1 = new JButton("Start");
JButton but2 = new JButton("Start");
boolean x = false;
boolean y = false;
public sound(){
super("sound");
setSize(150,150);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
clip1 = Applet.newAudioClip("FIRED.WAV");
clip2 = Applet.newAudioClip("FIRED.WAV");
but1.addActionListener(this);
but2.addActionListener(this);
JPanel paneButton = new JPanel();
paneButton.setLayout(new GridLayout(1,2,15,15));
paneButton.add(but1);
paneButton.add(but2);
JPanel pane = new JPanel();
pane.setLayout(new BorderLayout());
pane.add(paneButton);
setContentPane(pane);
show();
}
public static void main(String args[]){
sound Frame = new sound();
}
public void actionPerformed(ActionEvent e){
Object source = e.getSource();
if (source == but1){
if (x){
//but1.setValue("Stop");
clip1.play();
x = false;
}
else
{
//but1.setValue("Start");
clip1.stop();
x = true;
}
}
else
if (source == but2){
if {
//but2.setValue("Stop");
clip2.play();
y = false;
}
else
{
//but2.setValue("Start");
clip2.stop();
y = true;
}
}
}
}请问这段代码错在哪里啊,程序提示"clip1 = Applet.newAudioClip("FIRED.WAV");
clip2 = Applet.newAudioClip("FIRED.WAV");"
出错啊,谢谢
import java.applet.AudioClip;
import java.awt.event.*;
import javax.swing.*;
public class sound extends JFrame implements ActionListener{
AudioClip clip1;
AudioClip clip2;
JButton but1 = new JButton("Start");
JButton but2 = new JButton("Start");
boolean x = false;
boolean y = false;
public sound(){
super("sound");
setSize(150,150);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
clip1 = Applet.newAudioClip("FIRED.WAV");
clip2 = Applet.newAudioClip("FIRED.WAV");
but1.addActionListener(this);
but2.addActionListener(this);
JPanel paneButton = new JPanel();
paneButton.setLayout(new GridLayout(1,2,15,15));
paneButton.add(but1);
paneButton.add(but2);
JPanel pane = new JPanel();
pane.setLayout(new BorderLayout());
pane.add(paneButton);
setContentPane(pane);
show();
}
public static void main(String args[]){
sound Frame = new sound();
}
public void actionPerformed(ActionEvent e){
Object source = e.getSource();
if (source == but1){
if (x){
//but1.setValue("Stop");
clip1.play();
x = false;
}
else
{
//but1.setValue("Start");
clip1.stop();
x = true;
}
}
else
if (source == but2){
if {
//but2.setValue("Stop");
clip2.play();
y = false;
}
else
{
//but2.setValue("Start");
clip2.stop();
y = true;
}
}
}
}请问这段代码错在哪里啊,程序提示"clip1 = Applet.newAudioClip("FIRED.WAV");
clip2 = Applet.newAudioClip("FIRED.WAV");"
出错啊,谢谢