The applet shown at is not a real simulation.
It just use java to draw what you would expect.
You should be able to use EJS to do the same thing easily.
Try it. And I will help you.
And EJS can even create a real simulation, for example: what if the mass is different.

You can create a real simulation if you modify Simulations\\BallsInBox.xml