I have this current code written in my program that is supposed to start the timer, however the code does not work. The timer does not start and I'm pretty sure that I missed something out.
private Timer timer;
private void StartStopTimerActionPerformed(java.awt.event.ActionEvent evt) {
timer = new Timer(5000,new ActionListener(){
@Override
public void actionPerformed(ActionEvent evt) {
}
});
StartStopTimer.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!timer.isRunning()) {
timer.start(); AddOneActionPerformed(evt);
} else {
timer.stop();
}
}
});
}
The private class is right at the top of my program and the rest of the code is located in a button.