1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| package test;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Play extends JFrame
{
private static final long serialVersionUID = 4728920536811198811L;
protected Timer jolieTimer;
public Play() throws HeadlessException
{
super();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle(":)");
int delay = 1000; //milliseconds
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
System.out.println(java.util.Calendar.getInstance().getTime().toString());
}
};
setVisible(true);
jolieTimer = new Timer(delay, taskPerformer);
jolieTimer.start();
}
/**
* @param args
*/
public static void main(String[] args)
{
new Play();
}
} |
Partager