日期:2014-05-20  浏览次数:20601 次

谁帮我看下这个程序,说我没重写方法,但是我确实是API复制的啊。
Java code

import java.awt.*;
import java.awt.event.*;

public class ActionEvent{
    public static void main(String[] args){
        Frame f = new Frame("xiaohua");
        Button b = new Button();
        Monitor m = new Monitor();
        b.addActionListener(m);
        f.pack();
        f.setVisible(true);
        }
    }
    
class Monitor implements ActionListener{
    void actionPerformed(ActionEvent e) {  //actionPerformed(ActionEvent)
        System.out.println("cool boy");
        }
    }




ActionEvent.java:15: 错误: Monitor不是抽象的, 并且未覆盖ActionListener中的抽象方
法actionPerformed(ActionEvent)

------解决方案--------------------
Java code

class Monitor implements ActionListener{
    public void actionPerformed(java.awt.event.ActionEvent e) { 
        System.out.println("cool boy");
        }
    }