由于错误,它不会让我运行程序:
类型BingoHelper
必须实现继承的抽象方法ActionListener.actionPerformed(ActionEvent)
public class BingoHelper extends JFrame implements WindowListener, ActionListener{
JButton b = new JButton(new AbstractAction("Enter"){
public void actionPerformed (ActionEvent e){
答案 0 :(得分:1)
BingoHelper类未实现actionPerformed
。扩展AbstractAction
的匿名类确实实现了它,但它不是一回事。
答案 1 :(得分:1)
actionPerformed
方法不是BingoHelper
的成员。您应该创建类BingoHelper
的方法并实现它。
public class BingoHelper extends JFrame implements WindowListener, ActionListener{
public void actionPerformed (ActionEvent e){}
答案 2 :(得分: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
界面并实施actionPerformed
AbstractAction
方法
public class BingoHelper extends JFrame implements WindowListener {
JButton b = new JButton(new AbstractAction("Enter"){
public void actionPerformed (ActionEvent e){...}
};