Java timer

Associate
Joined
18 Mar 2007
Posts
291
Hey,

I'm trying to pass a variable to the Timer() constructor. I am receiving the following error message:

cannot resolve symbol - constructor Timer(double, Spawn.Ticker)

I have a function in my code that returns a random double, which is the number that I want to pass to the first bit of Timer().

The code looks like this:

Code:
double a = getRandomDouble(0.3,0.9);
Timer t = new Timer(a, new Ticker());
t.start();

and the getRandomDouble is:

Code:
private double getRandomDouble(double lower, double higher)


Anyone know how I can pass a variable to the Timer constructor?

Cheers, Rob
 
Well javax.swing.Timer is expecting an integer and an ActionListener as a parameter to the constructor and your giving it a double and Spawn.Ticker(I don't know the type) so you need to be giving it the correct types.

Timer(int delay, ActionListener listener)
 
Back
Top Bottom