0
I’m using Swing in Netbeans, creating a simple math game (thought more feasible than a calculator) whose goal is to add up the random numbers of the buttons until it equals a number between 1 and 10000, which would be shown randomly. I used for
to try something cool, do something like a simple timer to make the game harder. So far, apart from the fact that Netbeans asked to add a try
,catch
, does not present any error, however, the jLabel
lblGameTime
not counting the time.
Here’s my Method (or rather, what I managed to do, because I know I did wrong, I just don’t know where):
public void GameTime() {
int seconds = 120;
for (int i = seconds; i < 0; i++) {
lblGameTime.setText(String.valueOf(i));
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException ex) {
Logger.getLogger(tela1.class.getName()).log(Level.SEVERE, null, ex);
}
}
}