The Java source code for this applet can be found here.
I have left his code so you could see the nice use of "meaningful" variable names and comments.