I have modified the code according to what you would like to do:
You can change the slider to modify mass ratio between different balls.
The initial mass ratio are: m2:m1=5./3.; m3:m2=2:1, m4:m3=3:1
Just hit [b]play [/b]and you will find out. You can change it to other ratios.
-*-
If initial mass ratio are 1:2:10:30 (m21=2, m32=5, m43=3) :only the last one will be stopped.

/htdocs/ntnujava/ejsuser/2/users/ntnu/fkh/ballsInBoxfkh3_pkg/ballsInBoxfkh3.propertiesFull screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
Press the Alt key and the left mouse button to drag the applet off the browser and onto the desktop. This work is licensed under a Creative Commons Attribution 2.5 Taiwan License
Download EJS jar file(807.9kB):double click downloaded file to run it. (1 times by 1 users) , Download EJS source (1 times by 1 users) View EJS source