0

由于错误,它不会让我运行程序:类型BingoHelper必须实现继承的抽象方法ActionListener.actionPerformed(ActionEvent)

public class BingoHelper extends JFrame implements WindowListener, ActionListener{
JButton b = new JButton(new AbstractAction("Enter"){

                public void actionPerformed (ActionEvent e){
4

3 回答 3

1

actionPerformed方法不是 的成员BingoHelper。您应该创建该类的方法BingoHelper并实现它。

public class BingoHelper extends JFrame implements WindowListener, ActionListener{
  public void actionPerformed (ActionEvent e){}
于 2013-10-20T20:12:23.857 回答
1

BingoHelper 类没有实现actionPerformed. 您扩展的匿名类AbstractAction确实实现了它,但它不是一回事。

于 2013-10-20T20:10:14.203 回答
1

从 中删除匿名侦听器JButton并实现actionPerformed内部BingoHelper并向其注册按钮操作侦听器

public class BingoHelper extends JFrame implements WindowListener, ActionListener {
    JButton b = new JButton("Enter");

    //...

    b.addActionListener(this);

    //...

    public void actionPerformed(ActionEvent evt) {...}

或从中删除ActionListener接口并BingoHelper实现actionPerformedAbstractAction

 public class BingoHelper extends JFrame implements WindowListener {
    JButton b = new JButton(new AbstractAction("Enter"){
        public void actionPerformed (ActionEvent e){...}
    };
于 2013-10-20T20:52:42.117 回答