Java Applets &
JavaScript
PAGE (4 of 7)

Example Java Applet

The following is a Java applet button, -- written by Eric C. Harshbarger of Sun Microsystems' New Media Group. Move the cursor back and forth over the cs1205 button image to see the applet in action. Selecting the CS1205 button will open the VT home page @ www.vt.edu, (use the browser back button to return to this page).

Imbedding a Java Applet

Step 1:

View the documentation for the Java applet button.

Step 2:

Download the Java applet button tar file from Café del Sol. Use WinZip to expand the Java button tar file. If WinZip is unavailable, download and use TAR for Windows for the expansion.

Step 3:

Launch Arachnophilia or another HTML editor from the menu. Create a simple HTML file to hold the button applet. You will optionally need two small GIFs for the unselected and depressed button images. The Java button applet tar file comes with two images that may be used for trial purposes.

Step 4:

Enter the following applet tags in your HTML code:

<applet code=Button1.class width=96 height=38 align=absmiddle>
<param name=COPYRIGHT value="Button applet, Copyright 1997 Sun Microsystems, Inc., all rights reserved.">
<param name=DOCUMENTATION value="Documentation found at: http://www.xm.com/cafe/">
<param name=HIGHLIGHT value="true">
<param name=URL value="URL of linked document">
<param name=TARGET value="new">
<param name=BASE.BGCOLOR value="white">
<param name=BASE.FGCOLOR value="black">
<param name=BASE.TEXT value="Text message for button">
<param name=BASE.FONTNAME value="TimesRoman">
<param name=BASE.FONTSTYLE value="plain">
<param name=BASE.FONTSIZE value="12">
<param name=BASE.IMAGE value="location of initial GIF">
<param name=ENTER.TEXT value="Text label for button">
<param name=ENTER.FGCOLOR value="blue">
<param name=ENTER.BGCOLOR value="white">
<param name=ENTER.FONTSIZE value="10">
<param name=ENTER.IMAGE value="location of depressed GIF">
<param name=CLICK.SOUND value="bubble.au">
</applet>
Replace any of the parameters with your own arguments. The parameters that must be replaced are listed in boldface and italized. Refer to the online documentation for the Java applet button for explanations of the parameters. You may optionally view the source of this HTML document to see how the Java button applet was imbedded at the start of the document.

Step 5:

Try out your HTML page by opening it in a Web browser. Experiment with the applet parameters until you achieve the desired layout you wish.

Step 6: (optional)

Visit the Web sites below and surf their collections of Java applets to locate applets for use in your own Web pages.

 

Java Applet Resources

 


© CS Dept Va Tech, 1997-1998.

All rights reserved.