Fade Java Sample Applet
The Java applet below does a crossfade between two images. You can change the behaviour of the applet by playing with a few JavaScript controls that will appear below the applet (if your browser is JavaScript enabled). The original Fade.java code demonstrated an interesting problem with Java (which was pretty severe under Netscape). Since the original version created all the crossfade images in the fade sequence on the fly, it was possible for the thread creating images to produce more garbage than the garbage collector could collect. Eventually, the system would run out of memory. The new version here has been optimized to cache any images it has already produced to avoid this problem and speed up the crossfade. Also, the new version is admittedly less object oriented, but loads faster because I implemented the CrossFadeImageProducer inline in the Fade applet class (ie., the Fade applet simply "implements Runnable, ImageProducer").
The original Fade applet source code (Fade.java)
The optimized Fade applet source code (Fade.java)