Hello! I'd like to start off with saying I am a real beginner with JAVA. I am creating a mouse-click game where you need to click the button as many times as you can within 15 seconds. I have the button and the score working, all I need is a timer that can count down from 15. I know there are swing timers and there are util timers and it would be prefered if I could use a util timer. Here is the code i have so far:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.Timer;
import java.util.TimerTask;
public class MouseCickGame extends Applet implements ActionListener
{
int counter = 0;
Button Click = new Button ("Click Me!");
Label Score = new Label (" Score: ");
Label Timer = new Label ();
public void init ()
{
GridLayout grid = new GridLayout (3, 3);
setLayout (grid);
add (Click);
Click.addActionListener (this);
add (Score);
add (Timer);
}
public void actionPerformed (ActionEvent ae)
{
if (ae.getSource () == Click)
{
counter += 1;
}
Score.setText (" Score: " + counter);
}
}
I need to know how I can implement a timer into this code then have the button dissapear and the score displayed somewhere on the applet. Thanks!