import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class UseButton extends JPanel implements ActionListener
{
private String make;
private JButton button1;
private JButton button2;
public UseButton()
{
//buttonimp listener=new buttonimp();
button1=new JButton("显示1");
button1.setActionCommand("xsone");
button1.addActionListener(this);
button2=new JButton("显示2");
button2.setActionCommand("xstwo");
button2.addActionListener(this);
add(button1);
add(button2);
}
public void ActionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals("xsone"))
{
System.out.println ("1");
}
else
{
System.out.println ("2");
}
}
public static void main(String[] args){
JFrame ub=new JFrame("Frame");
ub.getContentPane().add(new UseButton());
ub.setSize(300,200);
ub.setVisible(true);
}
}
我刚刚学JAVA,这段例子,改来改去,基本上已经和书上一样了,可是还提示我
UseButton is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
不懂错在那里,前辈门指点下我啊