|
|
||||||||||||
|
|
HTML | Java Applets |
|
|
|
||||||||
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.
We've added this to our page using the following HTML:
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,
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. If you are going to use applets that are not in the same
directory the HTML file that calls them, you may wish to review the section on
Relative Addressing.
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:
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:
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 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.
|
||||||||||||
|
|
||||||||||||