For this game I'm making for java class, I want a timer display in the corner that counts up from `0`

I made a variable that represents seconds, which ==> double s =0;

My idea was that using a `Timer` object where I could increment the variable every second and use the `repaint()` method on the string

However, I misinterpreted how the timer object works, and after the delay it counts up rapidly to infinity. I have no idea what to do now. A hint would be appreciated.

Here is my code,thanks for any help:

```
 int delay = 5000; //milliseconds
  ActionListener taskPerformer = new ActionListener() {

    @Override
    public void actionPerformed(ActionEvent arg0) {
        s=(int)s+1;

    }
  };
  new Timer(delay, taskPerformer).start();
  String t = "" + s;
g.drawString(t, 100, 100);
repaint();

```