Timed Random number

Is there a way to create a random number timed? For example, I know how to create a random number but I need to be able to press a botton and create a random number every say 3-4 seconds.  That is what I am having trouble with, how to create a random number every x seconds.  I would press a button then the random number generator would start and give me a random number every x seconds, this will continue until I press another button at which button the random numbers would stop.
uriveraAsked:
Who is Participating?
 
objectsCommented:
that link has an example :)

put the code you want to get run in the run() method at

// Task here ...
0
 
objectsCommented:
0
 
uriveraAuthor Commented:
could you show some examples please, thanks
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> but I need to be able to press a botton

So you want to start at the button-click? Then you need to implement an ActionListener and add it to the button:

button.addActionListener ( yourActionListener ) ;

In the actionPerformed () method of the listener, start the timer.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.