Question 1: Reading Parameters from an HTML file.

  • Change the HelloWorld applet to read a text parameter from the HTML file example.html.
  • Change the example.html file to contain PARAM field in the applet description. The string's value must be "Hello there yourself".
  • Question 2: Change the HelloWorld applet from question 1, so that the string message being displayed is displayed in the Helvetica font, and is bold and in point size 18. You can either do this by using PARAMeters or hardcoding it in the program.

    Question 3: The following questions are about the HelloAnim applet:

  • Experiment with the Thread.sleep function. Change its sleep time to be 200 milliseconds.
  • Change the y-coordinate with each iteration of the loop so that the text moves up and down as well as right to left.
  • Change the applet so that it only starts the animation when the mouse enters the applet window, and stops the animation when the mouse leaves the applet window.
  • HINT: use the mouseEnter(Event event, int x, int y) and mouseExit(Event event, int x, int y) methods, but ignore their arguments. Events will be the topic of next week's lecture.

  • As you may have noticed, the applet window is initially empty. Change it to display the "Hello World!" string in the center of the screen on startup.
  • By now, your applet should look something like the following:

    Question 4: Double Buffering.

    Change the HelloWorld applet from question 1, so that the string message is drawn over a background image. The applet should load and draw the image using double buffering. Your applet should work as follows: when the image is not yet loaded, then only the string should be drawn on the screen (at location (150,125). When the image is loaded, then the image should be drawn on the screen, and then the text string at location (50,125). The width of your applet (in the HTML-file) and offscreen image should be 300 pixels. The height of your applet and offscreen image should be 250 pixels.

    The image you should use is: HELLO.GIF (in Netscape, you can save the image by clicking the right mouse button on it and choosing Save this image as... from the popup menu).

    Your applet should look like: HelloLab.


    Java Home
    Lectures
    Labs
    Lecture2