We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Timed Random number

urivera
urivera asked
on
Medium Priority
209 Views
Last Modified: 2011-09-20
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.
Comment
Watch Question

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:

Author

Commented:
could you show some examples please, thanks
Java Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
that link has an example :)

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

// Task here ...

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Mayank SPrincipal Technologist
CERTIFIED EXPERT

Commented:
>> 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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.