by Grace Roberts - GUI Online Productions
It seems we all agree that the internet has suddenly made object languages very popular, and that Java has become the standard. Everyone, from serious developers to marketing hypsters, have advised us to learn this language. It will even be embedded into the operating systems of many major vendors (including IBM, Novell and Microsoft). Java is a robust, flexible, complete development language - but the current craze is to use it for web page applets. Netscape was the first browser to recognise embedded applets, but some others are : CyberDog with CyberJava/OpenDoc, Oracle PowerBrowser, HotJava, and IBM WebExplorer. Java support for MSIE 3.0b is available, and Microsoft is coffee-talking with Jakarta.
It's easy to write your own applets, as long as you already
know C or C++.
...Great. Maybe in my next life I will have time for that.
You can, however, take advantage of others who have already written applets, and are nice enough to share their work. That's how we created the animated icon in this issue "Table of Contents". We downloaded a free applet from Sun Microsystems, appropriately called The Animator Applet. You have the option of getting the source code from them, or just the already-compiled class files. In order to compile the source into class files you need the Java compiler (available in Sun's Java Developers Kit). We opted for the class files.
We started by creating a series of seven gif files that cycle through our animation. The names of the files are cup0.gif, cup1.gif, etc. The html code, to include the applet on the page, is very straightforward:
<applet code="Animator.class" width="45" height="45"> <param name="imagesource" value="images/cups/"> <param name="startup" value="cup7.gif"> <param name="background" value="cup7.gif"> <param name="images" value="3|2|1|0|1|2|3|4|5|6|5|4|3|2|1|0|1|2"> <param name="namepattern" value="cup%N.gif"> <param name="pauses" value="100|100|100|1000|100|100|100|100|100| 1000|100|100|100|100|100|100|100|100"> <param name="repeat" value="true"> <img src="images/cups/cup7.gif" width=45 height=45 alt="Java Icon"> </applet>
The class file (Animator.class) is in the same directory as the html document. The param tags give the applet variable instructions, like the location of the animation images, frame sequence, and sound options. We decided against sound for this example. A detailed explanation of the tags is available from Sun. The img tag prior to the close of the applet is included for display in browsers that are not Java aware. (Sorry non java browsers!)
And here is the applet:
Shift-click over the applet for more information from the author.
Getting Started with Applets