IDE将Listener标记为红色并表示它不是抽象的

-5 java swing compiler-errors

这段代码有什么问题?:当我声明私有类Listener实现ActionListener时,IDE只将Listener标记为红色,并说它不是抽象的

package hello;  
import javax.swing.*;    
import java.awt.*;
import java.awt.event.*;

public class hello{

    private JFrame mainFrame;
    private JLabel title;
    private JPanel mainPanel;

    public hello(){
        prepareGUI();
    }

    public static void main(String[] args){
        hello helloo = new hello();
        helloo.Event();
    }

    private void prepareGUI(){
        mainFrame = new JFrame("This is a test project");
        mainFrame.setSize(500, 500);
        mainFrame.setLayout(new GridLayout(3,1));

        mainPanel = new JPanel();
        mainPanel.setLayout(new FlowLayout());

        title = new JLabel("",JLabel.CENTER);

        mainFrame.add(mainPanel);
        mainFrame.add(title);
        mainFrame.setVisible(true);
    }

    private void Event(){
        JButton button1 = new JButton("Test");
        button1.setSize(15,10);
        button1.setActionCommand("Test");
        button1.addActionListener(new Listener());

        mainPanel.add(button1);

        mainFrame.setVisible(true);
    }

    private class Listener implements ActionListener{
        public void action(ActionEvent e){
            String com = e.getActionCommand();
            if(com.equals("Test")){
                title.setText("button clicked");
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我是JAVA的新手,昨天开始,所以任何建议都会有用PS我正在使用NetBeans IDE 7.4

Obi*_*ere 5

您尚未实现ActionListener接口所需的方法.

在该课程的某个地方,填写:

@Override
public void actionPerformed(ActionEvent e){
    // Fill
}
Run Code Online (Sandbox Code Playgroud)

你有一个action(ActionEvent)方法,但拼错了.