有Timer类,就是用来表示定时器控件的

解决方案 »

  1.   

    //给你看个我编的TimerTest程序看了就知道了
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.Timer;public class TimerTest
    {
    public static void main(String[] args)
    {
    ActionListener listener=new TimePrinter(); Timer t=new Timer(1000,listener);
    t.start(); JOptionPane.showMessageDialog(null,
    "注意看Console的变化,会有时间自动显示,按“确定”退出演示");
    System.exit(0);
    }
    }class TimePrinter implements ActionListener
    {
    public void actionPerformed(ActionEvent event)
    {
    Date now = new Date();
    System.out.println("现在时间 "+now);
    }
    }