I don’t kno whats wrong with your code but I always use the swing timer like this (see below) and it works a lot for me.
Timer we;//your timer
int interval = 10000;//10 seconds
we = new Timer(interval, new ActionListener(){
public void actionPerformed(ActionEvent e){
//do something here
}
});
//here we tell it to start
we.start();
//this optional, if x is true, then the timer will repeat infinitively
//every y seconds, where y is the delay (or interval)
//otherwise it’ll wait y seconds and do its job once and stop
we.setRepeats(boolean x);
Maybe you’ll have some problems accesing variables inside the inner actionlistener, the compiller will say that you need to declare the variable final) But you can make your own class then add any variable you may need as global and make them point to anyother variable that you may need to use inside the actionlistener
Something else that you should consider is that if your going to put some animation lets say… inside your game loop then you have to tell it that when your timer starts running don’t start it again anymore otherwise it’ll make it start over and over again causing undesired behavor, you can use a boolean for that purpose or access the timer method isRunning().