Simpel timer der ikke virker
Er der nogen der kan sige mig hvorfor denne timer ikke virker ?import java.awt.event.*;
import javax.swing.*;
import java.util.Calendar;
public class MyTimer {
int delay = 1000; //milliseconds
Timer t;
/** Creates a new instance of MyTimer */
public MyTimer() {
t = new javax.swing.Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
Calendar now = Calendar.getInstance();
int h = now.get(Calendar.HOUR_OF_DAY);
int m = now.get(Calendar.MINUTE);
int s = now.get(Calendar.SECOND);
System.out.println(h + ":" + m + ":" + s);
}
});
t.start();
}
public static void main(String[] args) {
MyTimer mt = new MyTimer();
}
}
