Adding Java Applets to Your Web Pages


In this self-study lab exercise I would like you to add a Java applets to a new Web page of your own design. You can post this new Web page to your publishing area and link it from your cartography projects page. The basic steps for the exercise are listed here, but you will also have to read the documentation that comes with the applet.

Mastering Java programming takes considerable time and study. However, inserting pre-programmed Java applets into Web pages is quite easy and is something you will master in this exercise. Many free applets are available in the Web and some of these will provide useful, useable functions for your Web pages--like graphic animation.

If questions arise as you work on this exercise, please ask your TA or other members of the class. You have the HTML editing and authoring skills needed to complete this exercise in. However, if the documentation is hard for you to understand, ask for assistance. In your extra time, experiment with the applets by varying their parameters or inserting other applets into your page.

Part I: Adding an image viewer applet

I would like you to insert a "viewer" in your page.  This viewer allows you to display gif and jpg files.  In this case I will provide you with seven maps of US population history that you can use with the viewer.

1.  For this exercise you need to use a browser (IE or Netscape) and Dreamweaver.  Launch both programs now.  Open Dreamweaver and create a new web html document in which you can manage your files.  Later, you will use SSH to move your new pages (and support files) to the server, but you don't need to launch SSH until you need it.

2. Look at the applet I would like you insert into your new Web page.  It is available from buddysoft.net.  When you go to this URL you can demo the viewer.  You will also find a "download" link which will allow you to download a free trial version of the viewer.


3.  Before you download these files, create some new folders. I want to add a new folder "java_applet" where I will download the Java applet.  And, within this folder I will also create an "images" folder where I will store the jpgs that the viewer will display.   

 

4. From http://www.5zed.com/download-now.jsp?id=396, download the compressed file "Slide_Show.zip" to your local disk, the default should be the Desktop. Double-click on "Slide_Show.zip", which will initiate the WinZip program. Chose the extract option, and extract the named "BuddySoft_Slide_Show" into your "java_applet" folder. This folder will have all the files you will need as well as the instructions on how to install the applet. Here is what my disk management looks like before I begin the exercise:

file management

Read the manual.htm page carefully. These are the instructions and the page also contains the HTML code that you will need to copy-and-paste into your Web page to get the applet to work. The three steps in these instructions have been integrated into this tutorial, so please follow the steps outlined here.

 

5. Download the jpgs for the applet here: http://www.colorado.edu/geography/foote/geog4043/assign/applet/download/animationframes.zip  If you extract the files during the download, be sure to extract them into the new "images" folder you have created.  If you download the zip file, put it in the "images" folder and extract the jpgs using WinZIP. File management should look like this:

file management 2


6. In Dreamweaver, create a new HTML file.  This is the page where the applet will appear.   I would recommend giving it a name such as "mapviewer.html" and saving it in the /java_applet folder. Add a title to this page like: "United States Population History: Periods When Counties Were Named, 1634-1983" Also, as usual, put your name and the date at the bottom of the page.

 7. Copy and paste slide_show.jar from the "BuddySoft_Slide_Show" folder into your java_applet folder. This file was originally extracted into the "BuddySoft_Slide_Show" folder.  File management should look like this:

file management 3

8. With the mapviewer.html file still open in Dreamweaver, change to "CODE view" by clicking the tab at the top of the viewing window. You must now copy some HTML code from manual.htm file into mapviewer.html. Follow the instructions in step two of the documentation. Notice that the HTML codes <applet> </applet> designate the location of a Java applet in a Web file.

9. Step three of the manual.htm instructions will ask you to copy and paste "sample_config.txt" into your new image folder. Do this step now and rename this text file something like "county_config". Don't put .txt at the end when you name it. Windows does this automatically, so if you do it, the file will be labeled "county_config.txt.txt" and won't work.

A. After you have followed the instructions in manual.htm and steps 7 & 8 from this tutorial, your mapviewer.html file will look something like this in CODE view:

code

     Also notice where the files slide_show.jar and county_config.txt have been saved.

B. Because I am supplying you with some jpg maps, your county_config.txt file (what was originally the sample_config_file.txt) should appear as follows:

img1.src = frame1634.jpg
img1.delay = 2000
img1.dir = fl
img1.url = self
img1.text1 = 1634

img2.src = frame1701.jpg
img2.delay = 2000
img2.dir = fl
img2.url = self
img2.text1 = 1701

img3.src = frame1751.jpg
img3.delay = 2000
img3.dir = fl
img3.url = self
img3.text1 = 1751

img4.src = frame1801.jpg
img4.delay = 2000
img4.dir = fl
img4.url  = self
img4.text1 = 1801

img5.src = frame1851.jpg
img5.delay = 2000
img5.dir = fl
img5.url = self
img5.text1 = 1851

img6.src = frame1901.jpg
img6.delay = 2000
img6.dir = fl
img6.url = self
img6.text1 = 1901

img7.src = frame1951.jpg
img7.delay = 2000
img7.dir = fl
img7.url = self
img7.text1 = 1951

====
.

10. Once the applet code is added to the file, and the config file changed to suit the images we will display, save these files, then preview the mapviewer.html file. You will have to change the "height" and "width" properties of the applet to fit the dimensions of the jpgs that you are trying to display in the slideshow.

 
11.  Once your mapviewer.html is working, move it to the server with SSH.  What files will you have to move to the server? Be sure to keep the files in their correct locations.

SSH
  

12.  Check that this page now runs on the server.  Once it does, make a link to it from your projects page (edit the projects page and then move it back to the server.)

13. Neat! Show your friends!  

14.  If you would like, remove substitute your own gifs or jpgs for the maps.  Customize the HTML code so the viewer will display your images..

Part II: Find and add another applet to your page

Now, find another useful applet to add to your page. Use a search engine to look for "free java applets."   I found this image viewer through http://www.freewarejava.com/  There are lots of "decorative" applets online--ones that blink, move, flash signs, morph graphics and so forth--but these aren't always very useful. Try instead to find an applet that you might be able to use to use in one of your projects to display maps--somthing that zooms, changes pages, open windows, etc.

Once you have found a useful applet, follow the documentation to add it to the page you created in Part I.

Finished early? Experiment with other applets or work on your final project.



Created 2001.9.24. trudeau@colorado.edu
Revised 2009.9.19 GJM