CP2003 - Tutorial Twelve: Applet of My Eye


For the twelth and final tutorial we are going to firstly look at some summary questions and then take a look at applets and how easy it is to make an applet out of an application.

  1. Firstly, some quick questions harking back to your early days of CP2003:

  2. The programming question for today is firstly to consider an already existing application (start with something slightly simpler like BallMover.java - don't forget to download the picture for the dialog box).

  3. The task now is to convert BallMover.java into an applet. There is a standard way of doing this: Firstly, you will need to use the class JApplet which is like a plain Applet but has its own content pane and a few other niceties. Here's what else you have to do:

    1. Remove the class with the main method in it.
    2. Inherit from JApplet, not JFrame.
    3. Remove the window listener.
    4. Remove the call to setSize and instead set the size in the applet's HTML page.
    5. Remove the call to setTitle.

  4. Compile your modified code.

  5. You'll need to write an accompanying HTML file (like the one in tutorial nine), and you should point your browser at this HTML file. Note that if the browser you are using is not a very recent version then you should use the program appletviewer which comes with the jdk (run it as appletviewer blah.html).

  6. If you make it this far, you might want to try to make your second assignment into an applet.


    Copyright © 2000. James Cook University. All rights reserved.