This does nothing
This does nothing This does nothing This does nothing This does nothing

Home
Back to the start

Next
Advance a page in this tutorial

Back
Return to the previous page

Help
Go to our message board

 

 

 

Java Applets

Even if you don't know how to program in Java, you can still employ Java applets that someone else has already written.

Java Example: TickerTape Applet

Many applets let users perform a degree of customization using only HTML commands. A nice example is the following ticker tape display developed by an Egyptian company named ITS.

Your browser does not support Java so it cannot display the demonstration applet. Netscape 3.0 for the Macintosh, Netscape2.0 for PC and Unix systems, and Internet Explorer 3.0 are examples of browsers that supportJava.

We've added this to our page using the following HTML:

<applet code=NavigatorTicker11.class width=300
height=28>
<param name=count value=2>
<param name=msg0 value=
"Welcome to Fred Fargle's Homepage.. Just Click 
to Connect *** \\No Link"> 
<param name=msg1 value=
"Visit:  ALCo -- Access LaPorte County
  \\http://www.alco.org/">
<param name=speed value=8>
<param name=bgco value=50,0,200>
<param name=txtco value=250,250,0>
<param name=linkco value=180,25,21>
</applet>

The actual Java program is in file NavigatorTicker11.class; this is a compiled binary file, in a platform independent format know as byte-code (compiled Java applets will generally have the extension .class in their filenames; they are often termed class files).

The CODE and CODEBASE Fields

Note that the Java code is not part of the HTML file but is only referenced by the HTML. An HTML applet tag is used to insert the applet on the page. The tag tells the browser the name (and location) of the file containing the Java code that is to be inserted on the page. The name is supplied through the statement

code=NavigatorTicker11.class.

In this example, it is implied that this class file is located in the same directory (folder) as this HTML document. You can also place the Java code in a directory other than the one containing the HTML file, but then you must specify the location of this new directory (relative to the HTML file) by providing a value for codebase. For example, if we were to add codebase=/Java/NavTicker inside the applet tag,

<applet codebase=/Java/NavTicker 
code=NavigatorTicker11.class width=300 
height=28>

we would indicate that the NavigatorTicker11.class file was in a subdirectory named NavTicker of a directory named Java that was itself a subdirectory of the directory containing the HTML file for this page. This could be useful, for example, if we have used the same applet in more than one document.

Specification of Applet Parameters

The other items in the above applet tag are specifications of parameters that allow the user to customize the behavior of the applet (these are the lines beginning with "param"). The meanings of the parameters for the TickerTape applet are:

  • count -- total number of messages (3 in the above example)
  • msg0, msg1, ...individual messages; note that the count starts with 0, not 1; each consists of the message text, followed by two backslashes, followed by a URL (linking the message to the URL)
  • txtco -- color of message text, coded as a (Red, Green, Blue) RGB triplet with the components separated by commas, and each component a number in the range 0-255 indicating the amount of red, green, and blue, respectively (for example, the triple 255, 255, 255 is white, 0, 0, 0 is black, and 0, 255, 0 is pure green).
  • bgco -- background color (denoted in the same format as txtco)
  • linkco -- active link color (same format as txtco)
  • speed -- specifies the scrolling speed

Note that each displayed message can contain a hypertext link. The URL for the link is displayed at the bottom of the browser window when the cursor is placed over that scrolling message. You can activate a link by clicking on it as it scrolls by. If a message does not contain a link you should still include two backslashes after the message text (followed by optional text that will be displayed at the bottom of the browser window when the cursor is placed over that message).

Add the TickerTape Applet to Your Page

You can add this ticker tape banner to your pages and have it display whatever message(s) you desire. You only need to get the file NavigatorTicker11.class, add the above section of HTML code to the desired spot on your page, and modify the parameters to show the messages you want in the colors and speed you like (remember to place the Java class file in the same directory as your homepage file unless you add a codebase specification to indicate which directory it is in). The applet is free for you to use. The author only asks that you give credit to its developer.

Customizing the Applet

Experiment with modifying the example:

  1. Change Fred's name to your own, to make the banner a greeting to your homepage.
  2. Add a fourth message. (Don't forget to update the value of the count parameter!)
  3. Change the background color to bright red (255,0,0).
  4. Change the text color to cyan (0,255,255).
  5. Experiment with changing the scrolling speed. What happens if you use values of the speed parameter greater than 8? Less than 8?
  6. Now customize the banner to display the messages that you would like for it to display and add it to your homepage.

Note: In some cases the applet may not be reloaded with the new parameters in effect if you simply reload the Web page. You may have to exit your browser and restart it in order to see the changes. Java is a rather new language on the Web and there still are some bugs in its implementation for many browsers.

Some More Examples

If you would like to add more applets to your Web pages, check out some additional examples at

  • http://www.javasoft.com/applets/applets.html

Be sure to download the class file (or files) and a sample applet tag showing what parameters can be set for any applets that you want to add to your pages. In all cases, give credit where credit is due if you are using someone else's applet.

Home | Next | Back | Help


Our FAQ's Search this Site E-mail Us!
The ABCD's of the Internet went online June 14, 2002. Because it's new, there may be some bugs we have yet to work out. If you do experience any problems, find mistakes, or want to make suggestions, please e-mail us by clicking the "contact" button above.
This web site has been made possible by a grant from the Michigan City Community Enrichment Corp. Click here to learn more.

 

Access LaPorte County
301 E. Eighth St. #101
Michigan City, IN 46360

Phone: 219-861-0940
Fax: 219-861-0942

 

To the Home Page Click to Email Us To the FAQ's Page