Cookbook Image


Welcome to the Java Cookbook! Here you'll find a number of example Web pages created with the "Cool Beans!" Java applets and scripts provided on the Java For Dummies CD-ROM.

WARNING! Your browser may eventually crumble under the stress of all the applets and scripts here. Unfortunately, Java is so new that most Java-savvy browsers aren't able to get through every link below without behaving erratically from time to time -- there's a whole lotta juice in these pages! You may have to quit your browser, or even restart your computer, after after a while: Consider it a Java overdose...In the near future, most browsers will be able to handle this much Java.

Mantis Development Corporation Home Page

Example 1 -- The standard MDC home page with one Java enhancement - a LivingLinks applet configured with the RedBlue plug-in effect animates the Living Desktop image at the bottom of the page. This animation is hyperlinked to a page on the Web, using the applet's URL parameter.

Example 2 -- Building on the previous example, this page animates the top banner by cycling though several images using the LivingLinks applet. Instead of animating the images in a loop (1, 2, 3, 1, 2, 3,1, 2, 3...), which is the default for this applet, the reverse parameter is used to animate them "Ping-Pong" style (1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3...).

Example 3 -- Building on examples 1 and 2 above, this page contains 3 LivingLinks applets. The new applet animates the Toys for Tots button in the middle of the page. Instead of animating multiple images, this applet is configured to use a background image (the blue banner) on which two Toys for Tots train images are animated. This technique (made possible using the backgroundImage, imageTop and imageLeft parameters) saves download time since the large banner graphic only has to be transferred over the wire once.

Example 4 -- A completely "Javaized" version of the MDC home page. Building on the previous 3 examples, all images in this page (except the "Life" and "Mantis" images at the bottom) are now displayed using the LivingLinks applet. The three new buttons in this example are NOT animated, but are simply displayed on the screen (using the <APPLET> tag HSPACE attribute to provide enough space between each) and tied to sounds. For each of these, a different inMessage parameter has been specified; this message will be displayed in the browsers status area when the mouse moves into the applet. In addition the Living For The World button takes advantage of this applet's multi-hyperlink ability (the links parameter) -- click on it to see! Finally, sound has been added to the top banner using the applet's various sound parameters -- place your mouse in this image to hear the blowing wind.

Example 5 -- This page is the same as example 4 above, with the exception of two enhancements: the "Fade" JavaScript is used to fade into the page (from black to white) when first loaded, and the background color of the page itself has been set to white. To ensure no gray space appears around the applets when running (or when they are loading), the background color of each has been set to white as well using the backgroundColor parameter. In addition, JavaScript has been added to the text hyperlink at the bottom of the page -- move your mouse over this link and keep your eye on the status area of your browser.

Mantis Development Corporation Artwork and Artist Pages

Example 1 -- This example animates the various buttons that normally appear on the "Artwork" home page. Each button is animated using the LivingLinks applet, using the <APPLET> tag HSPACE attribute to provide enough space between each. Configured to take advantage of this applet's sound capabilities, moving your cursor inside a button triggers a randomly selected sound file (configured to select sounds randomly using the inRandomSound parameter). In addition, the speed of each animation changes when your cursor is moved inside (configured using the inSpeed parameter). Clicking on an animation will give you a pop-up list of the Web pages corresponding to each button in the animation (configured using the links parameter).

Using this applet's multi-link capabilities allows any number of hyperlinks to be attached to an image or animation, saving precious download time and Web page real estate (only one image is needed to attach multiple hyperlinks, where standard HTML can only attach a single link to an image -- without LivingLinks, a separate image would be required for each link, or you would have to use CGI to create an "Image Map" capable of containing more than one link. However, even in the case of an Image Map, a multiple choice pop-up menu isn't possible).

Example 2 -- Building on the previous example, this page adds a digital clock to the lower right hand corner of the window using the display_clock() JavaScript.

Example 3 -- This version of the "Artwork" home page is brought to life with the LivingLinks applet configured to use the Fade plug-in effect. As with example 1 and 2 above, several of the buttons in this page are tied to sound files. Move your mouse inside the various buttons to find out which ones are have corresponding sounds.

Example 4 -- This is an example of the "Artists" home page, which uses LivingLinks the same way as example 1 above. The difference, however, is that no sounds are attached to these buttons.

Mantis Development Corporation Living For The World Pages

Example 1 -- The "Living For Children" home page is animated using several LivingLinks applets for each of the buttons it displays. Each of the buttons uses the same images, yet are animated at slightly different speeds. In addition, each applet is surrounded with a 3-D bevel to give the appearance of a real button (using the bevel parameter). Each applet in this page is configured using the ALIGN <APPLET> tag attribute to position the text that follows in the middle of the applet.

Example 2 -- The "Living For The Environment" home page uses LivingLinks to animate all the images on the page, including the main banner at the top of the page. Unlike the "Living For Children" example (above) which uses the ALIGN <APPLET> tag attribute to position text in the middle of the buttons on that page, this page doesn't use the ALIGN attribute. As a result, the text appears at the bottom of each button.

Toys For Tots Home Pages

Example 1 -- The Toys For Tots home page, which uses the LivingLinks applet to animate a Christmas tree and play sounds (an "out" sound has been specified in addition to several "in" sounds). The "out" sound automatically plays when the applet is finished loading, and has been set to loop. As a result, a welcome audio track is played when the page is loaded. Place your cursor inside the tree to hear different sound clips, and click on the tree for a navigation menu. The Christmas tree image in this page uses "transparency", and so the background color of this Web page shows through the transparent portions of the applet thanks to its ability to deal with GIF transparency (using the backgroundColor parameter -- see the "Dolphin" examples in the Misc. Example section below for details).

Example 2 -- The same page as seen in example 1 above, but this time animated using the RedBlue plug-in effect. Instead of having to download multiple images, as example 1 does, only one image is used -- considerable download time is saved as a result.

Example 3 -- The same page as seen in example 2 above, with the addition of a JavaScript scrolling text banner (the scroll_text() script) appearing at the top of the page.

Example 4 -- The same page as seen in example 3 above, with one significant change: the scrolling text is made possible thanks to the Marquee applet. Using the color parameters of this applet, back_color and text_color, the color of the text is set to red while the banner on which its rests is set to black. In addition, JavaScript has been added to the text hyperlinks at the bottom of the page -- move your mouse over these links and keep your eye on the status area of your browser.

Demon Systems Home Pages

Example 1 -- The Demon Systems home page, which uses three applets linked together to act as one. Specifically, the first two applets are "joined" using the <NOBR> (no break) tag so that they will always sit side by side: the second applet will NOT wrap around to the next line if the browser window isn't wide enough to accommodate both. Using this technique, the three applets seem to be one large applet. Unless you look at the source code, you have no visual clue that the page is made up of several applets.

Example 2 -- The same Demon Systems home page seen in example 1, with one addition: the "Fade" JavaScript is used to fade into the page (from white to black) when first loaded.

GeoSystems "Mapplet" Web Page

Example 1 -- The GeoSystems "Mapplet" page uses the LivingLinks applet to animate steam emerging from a coffee cup. This steam forms the word MapQuest, which is an interactive Web-based atlas that uses Java! The applet has been configured for one-click navigation using the URL parameter -- click on the animation to visit the MapQuest Web site.

Misc. Examples

Haunted House -- This Web page uses several LivingLinks applets and the "Fade" JavaScript to create a haunted house. In addition to using the applets to animate images on the screen, a technique to hide applets on the page is employed: Move your cursor around the page to bump into these hidden applets and see (or should we say hear?) what happens. These applets are hidden by configuring them to display an image that is the same color as the background of the Web page (black, in this case).

Dolphin 1-- This is an example of using transparent images in an animation. The spinning dolphin appears seamlessly on the Web Page because the images use a transparent background color. Since the LivingLinks applet knows how to handle transparent image, you can set the background color for the applet to be the same as the page as shown in this example.

Dolphin 2 -- The same as the Dolphin example above, but using a different background color.

JavaScript and Applets Combo -- This is an example of combining JavaScripts and applets on the same page. Here a scrolling text JavaScript (the scroll_text() script) is combined with a Java animation (the LivingLinks applet) and a few lines of JavaScript code that display the date and the time on the page.

JavaScript Button -- This example shows how to use JavaScript to create a new window and display a Web page inside of it. The window in this case contains a Java applet (a LivingLinks animation), although you can use and display any Web Page you'd like.

"Java Cookbook" Copyright  © 1996, Mantis Development Corporation.
All Rights Reserved.