hy everyone,

I have a problem, I am making a little program for a game; When I start my game the timer has to start counting and after 3 minutes the game has to stop.
I need to know a way to program a very simple counter/timer in order to do this.

Can anyone help?:)

greets.
Stroper

thx!

Did you not realize this is wrong? Or did you just copy and paste the code =.=

int timeLeft = 180;
Timer countdown = new Timer(1000,new ActionListener(){
timeLeft--;
if(timeLeft <= 0){
// countdown finished
}else{
// Guess
}
});

Yeah I figured it before but I respecified my question because it might have been my fold.
It still doesn't work though; What's wrong?

package Boggle;

import java.awt.event.ActionListener;
import java.util.Timer;

/**
 * Created by IntelliJ IDEA.
 * To change this template use File | Settings | File Templates.
 */
public class Boggle {
    public void guess(){
        System.out.println("Guess");  
    }
    public void endGame(){
        System.out.println("End game");  
    }

    int timeLeft = 180;
    Timer countdown = new Timer(1000, new ActionListener() {
        timeLeft--;
        if(timeLeft<=0)

        {
            // countdown finished
        }

        else

        {
            // Guess
        }
    });

Show me your whole code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.