Hi!
I want to create a stopwatch that will counter seconds starting from 0. This code worked in case of a real time counter (using Calendar). However, now the counter is fixed on 0. Does anybody know what could cause an error? Thanks!
timer = new javax.swing.Timer(1000,
new ActionListener() {
public void actionPerformed(ActionEvent e) {
long start = System.currentTimeMillis();
long elapsedTimeMillis = System.currentTimeMillis()-start;
float elapsedTimeSec = elapsedTimeMillis/1000F;
jTextField.setText(Float.toString(elapsedTimeSec));
}
});
timer.setInitialDelay(0);
timer.start();