• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • Last Modified:

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.
0
urivera
Asked:
urivera
  • 2
1 Solution
 
objectsCommented:
0
 
uriveraAuthor Commented:
could you show some examples please, thanks
0
 
objectsCommented:
that link has an example :)

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

// Task here ...
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now