- 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"); } }