Timer(int delay,ActionListener listener)用于建立一个新的定时器,以便将事件发送给监听器.参数:delay 两个事件通知之间的延迟时间,以毫秒为单位; listener 当延迟时间结束时,要将这个情况通知到执行动作的监听器.不知道这样写是否懂,要是有事件的概念就应该可以懂了.其实这个计时器跟VB里的时钟控件差不多的.也是java里多线程的一种简化.通俗说就是到了你设置的时间间隔后,就执行你在监听器里写的代码.OK???

解决方案 »

  1.   

    Timer
    public Timer(int delay,
                 ActionListener listener)
    Creates a Timer that will notify its listeners every delay milliseconds. If delay is less than or equal to zero the timer will fire as soon as it is started. If listener is not null, it's registered as an action listener on the timer. Parameters:
    delay - the number of milliseconds between action events
    listener - an initial listener; can be null
    这种问题以后不要问了,自己去查一下就知道了。