Inserting JAVA Applets into Web Pages
Java Applets are small, self-contained programs that can be placed on web
pages. In this exercise, we will go through the steps of downloading a
Java applet and other required files, viewing the source code that calls the
Applet, and copying and inserting this source code into a page of our own.
- Obtain the Java applet (this step has been done for you). To
obtain the applet we went to the Java boutique and downloaded an applet that
takes any text you supply and applies a rather interesting effect. The
source for the applet we will use is: http://javaboutique.internet.com/Flame/.
We have already downloaded this file, unzipped it to extract the files, and
transferred it to a computer in the lab. To work with this applet, you will
need to download the entire folder that contains the applet. We will
tell you which folder to download.
- Open the folder that contains the applet (in this case "Flame").
In Internet Explorer Open the file flame.htm. Watch what
happens carefully.
- Under the View menu, choose Source. Select all the
text in between the opening and closing tags for the applet tag
(<applet . . . . .. . . . . </applet>).
- Open a New (Normal) Page in Microsoft Front Page.
- Choose Edit/Paste Special. Choose Treat as HTML and
click OK.
- Surprise- you've pasted a big J. Doesn't look like much does it?
This is just FrontPage's way of saying you've pasted in a Java applet.
Click on the HTML tab to see the good stuff.
- By now you should be able to guess which items you can change to customize
the applet for your needs. Go for it!
- The HTML you just pasted is not a Java applet. It is just the
code that calls the applet. The applet is a separate file called flame.class.
The HTML you pasted into your page, specifies that the class file you
created is in the same directory as the web page. Often there will
often be associated image and other files that need to be in specific
locations. If you don't put all the pieces of a Java applet in the
right place it won't work. For this exercise, this is pretty easy.
Simply save the Web page you just created in the Flame folder you
just copied. Once you do this, you should be able to click the Preview
tab, and view your new creation.
- To record the efforts of your labors for credit, rename the Flame folder
to "your name" and move it to the shared drive as instructed
in class.
Extra Credit: Time to strike out on your own. We will show
you a few other example in lab. Go to Java
Boutique, and download another applet. Try and choose a simple one.
Unzip the applet, find the source code, copy it, paste it as html into a new
document, modify it to suit your tastes and save it to to the right location.
If you've done everything right, it should work just like the last one.
GOOD WORK !
A couple of Java references:
Sun's Java Site: http://java.sun.com
A gateway to a wealth of information form the creators of Java.
Java Boutique: http://javaboutique.internet.com
A huge source of free applets and instuctions on how to use them.