The code is based in part on Sun's demonstration code for the JDK.