废话不多说直接上代码。应用于各位程序计时。
代码:
import javax.swing.*;
import java.util.Date;
public class Main{
public static void main(String[] args) {
// TODO Auto-generated method stub
javax.swing.Timer time=new javax.swing.Timer(500,new A());
time.setInitialDelay(0);
time.start();
}
}
class A extends JLabel implements java.awt.event.ActionListener {
public void actionPerformed(java.awt.event.ActionEvent e){
System.out.println(new Date());
}
}
效果图: