The Open Source Physics website will be unavailable Friday evening through Saturday afternoon as electrical work occurs in the American Center of Physics server room. Down time will begin at 6PM Eastern Time on Friday. Service is expected to resume by 6PM on Saturday, July 30.

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Problem with code in On Release of a Slider View

Return to the EJS Modeling forum
Login to post to this thread

Function to return an integer problem - Apr 19, 2013 at 9:01AM
Eoghan Miggan
1 Posts

Hey, so I wrote a function to get a random number between two value ranges as so:

public int getRandomNumber(int lowest, int highest){

int num = highest - lowest;

Random rand = new Random();
int i = rand.nextInt(num) + lowest;

return i;


For example if I was to say N = getRandomNumber(340, 385); and call this in the evolution page then it works and returns a random number between 340-385 over and over and over when play() it clicked.

But when I call this function in the On Release code of a Slider view, it only returns int's of values 1-9.

Does anyone know why this is?

The OSP Network:
Open Source Physics - Tracker - EJS Modeling
Physlet Physics
Physlet Quantum Physics