Hi!
I would like to add a timer to JTextField. However, my timer does not run. Could you, please, tell me what is wrong in my code. Thanks!
timerTask = new MyTimerTask();
timer.schedule(timerTask, new Date(0), 5000); // 5 seconds delay
...
private class MyTimerTask extends TimerTask {
@Override public void run() {
SwingUtilities.invokeLater(new Runnable(){
public void run() {
Date date = new Date(0);
SimpleDateFormat format = new SimpleDateFormat("mm:ss");
String current_time = format.format(date);
taskUptime.setText(current_time);
}
});
}
}