/**
 *@version 1.00 2000-04-13
 *@author Cay Horstmann
 */
 
 import java.awt.*;
 import java.awt.event.*;
 import java.util.*;
 import javax.swing.*;
 import javax.swing.Timer;
 //to resolve conflict with java.util.Timer
 
 public class TimerTest
 {
   public static void main(String[] args)
   {
     ActionListener listener = new TimePrinter();
 
 //construct a timer that calls the listener
 //once every 10 seconds
 Timer t = new Timer(10000,listener);
 t.start();
 
 JOptionPane.showMessageDialog(null, "Quit program?");
 System.exit(0);
   }
 }
 
 class TimePrinter implements ActionListener
 {
   public void actionPerformend(ActionEvent event)
   {
     Date now = new Date();
 System.out.println("At the tone, the time is " + now);
 Toolkit.getDefaultToolkit().beep();
   }
 }
我是照着打的,但是提示:
D:\java code>javac TimerTest.java
TimerTest.java:29: TimePrinter 不是抽象的,并且未覆盖 java.awt.event.ActionListe
ner 中的抽象方法 actionPerformed(java.awt.event.ActionEvent)
 class TimePrinter implements ActionListener
 ^
1 错误

解决方案 »

  1.   

    public void actionPerformend(ActionEvent event)
    ner 中的抽象方法 actionPerformed(java.awt.event.ActionEvent)
      

  2.   


    class TimePrinter implements ActionListener {
    public void actionPerformed(ActionEvent event) {
    Date now = new Date();
    System.out.println("At the tone, the time is " + now);
    Toolkit.getDefaultToolkit().beep();
    }
    }
    你写错了  actionPerformed 仔细看看
      

  3.   

    楼主敲错了一个单词,public void actionPerformed(ActionEvent event)方法是在ActionListener接口要实现的
    而你敲成了actionPerformend,所以会报TimePrinter没有实现ActionListener里面的抽象接口