import java.awt.*;
import java.awt.event.*;
import javax.swing.*;import java.util.*;
import javax.swing.Timer;public class TestAnonymousClass {
public static void main(String[] args){
TalkingClock clock = new TalkingClock();
clock.start(1000,true);
JOptionPane.showMessageDialog(null,"Quit program?");
System.exit(0);
}
}class TalkingClock{
public void start(int interval,final boolean beep){
ActionListener listener = new ActionListener(){
public void actionPerformed(ActionEvent event){
Date now = new Date();
System.out.println("At the tone,the time is"+now);
if(beep)Toolkit.getDefaultToolkit().beep();
}
};
Timer t = new Timer(interval,listener);
t.start();
}
}
为什么缺了这两句话,线程推出了 希望高手能帮我看下这个问题啊 最好讲明白点 谢谢
import java.awt.event.*;
import javax.swing.*;import java.util.*;
import javax.swing.Timer;public class TestAnonymousClass {
public static void main(String[] args){
TalkingClock clock = new TalkingClock();
clock.start(1000,true);
JOptionPane.showMessageDialog(null,"Quit program?");
System.exit(0);
}
}class TalkingClock{
public void start(int interval,final boolean beep){
ActionListener listener = new ActionListener(){
public void actionPerformed(ActionEvent event){
Date now = new Date();
System.out.println("At the tone,the time is"+now);
if(beep)Toolkit.getDefaultToolkit().beep();
}
};
Timer t = new Timer(interval,listener);
t.start();
}
}
为什么缺了这两句话,线程推出了 希望高手能帮我看下这个问题啊 最好讲明白点 谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货