Please help!! Kill Timer Action Lisenter

Joined
Jun 29, 2010
Messages
1
Reaction score
0
Does anyone know how to kill following Timer listener action? i have tried very hard, but still duno how to kill it..

Thanks

--------------------------------------------------------------------------------

int timeRemaining =10;
int timing=60000;
Timer countdownTimer = new Timer(timing, new CountdownTimerListener()); // Initial game time


public void CountDownTimer(int timing, int timeRemaining) {
System.out.println("countdown time");

if ( countdownTimer.isRunning())
{
System.out.println("is running - inside ");
countdownTimer.stop();
}
else
{
System.out.println("no running - inside ");
countdownTimer.start();
}

}

class CountdownTimerListener implements ActionListener
{
public void actionPerformed(ActionEvent e) {
--timeRemaining;
if (timeRemaining ==5)
{
String timervalue=String.valueOf(timeRemaining);
System.out.println(timervalue);
timeRemaining=10;
}
else if (timeRemaining >5) {
String timervalue=String.valueOf(timeRemaining);
System.out.println("timeRemaining"+timeRemaining);
System.out.println("show only");
}
else if (timeRemaining==11) {
System.out.println("stop only");
countdownTimer.stop();
}
else {
System.out.println("timeRemaining"+timeRemaining);
timeRemaining=10;
countdownTimer.stop();
} }
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top