CS 111: Fundamentals of Programming I

Lab 10

Goals

The primary goal of this lab is to convert one of your Java application programs into an applet and to have it execute from your web page.

Setting up your folder

  1. Choose one of your working Java programs that uses a GUI interface. Make a copy of the project folder and rename the copy as Applet.
  2. Copy the BreezySwing folder from the course folder into the Applet folder.

Creating your HTML file

  1. If need be, review the Powerpoint slides on HTML.
  2. Use some simple text editor to create a file called myApplet.html. Your page should be in your Applet folder and should include
  3. Test your file by opening it with the Mozilla browser (or other browser if you are working elsewhere).

Changing your Java program

  1. Change GBFrame to GBApplet
  2. Take out any setTitle commands
  3. Change the constructor to public void init()
  4. Delete the entire method main

Try it out with appletviewer

  1. Use the right mouse button on your main class and choose "run applet"
  2. Choose "run applet in appletviewer"

Add applet to web page

  1. At the appropriate place in your html file add the Applet tags:

    <APPLET CODE = yourprogname.class WIDTH= ? HEIGHT=?></APPLET> with actual values for the "yourprogname" and the width and height.

  2. Save your file

Move your Applet folder into your public_html folder.

Note: It is best not to try to use BlueJ to work with projects that are in the public_html folder. Use BlueJ on projects in your usual working directory and then move them to the public_html folder.

Try it out with browser

  1. Now try opening your HTML file with Mozilla
  2. If all goes well, your program should run on your web page
  3. You should be able to access this from anywhere on the internet using a url like

    "http://www.cs.wlu.edu/~yourname/Applet/myApplet.html"

If all of this works

Show your working web page to the lab assistant or me so we can check you off as having completed the lab assignment.

Name:

Checked: