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.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mick BarryJava DeveloperCommented:
uriveraAuthor Commented:
could you show some examples please, thanks
Mick BarryJava DeveloperCommented:
that link has an example :)

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

// Task here ...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.