Sealevel Software Logo Sealevel Software Logo



Sealevel Fade Java Sample Applet Rated Top 25% WebApplet by JARS

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)



If you have JavaScript in your browser, you can use these controls to play with the behaviour of the crossfade applet. By changing the delay field, you can make the dissolve go slower or more quickly. If your machine can't keep up, part or all of the delay will be ignored by the Java applet. The other field you can change determines how many intermediate frames to show during the dissolve. Once you have changed either field to your liking, simply click the "update" button and the dissolve will change accordingly.

Delay time between frames in milliseconds (0 to 1000):

Number of frames in dissolve (including the start and end frames) (2 to 100):



Return to the Sealevel Software Home Page.
Please send your comments to WebMaster@SealevelSoftware.com
All contents are copyright ©1995-96 by Sealevel Software. Last revised 17-Jul-96.
URL: http://www.SealevelSoftware.com/sealevel/fade.htm

Counter Bitmap