Running a simple applet

Object

To test understanding of applets, their implementation and use. The textbook reference is chapter 6, pages 149 to 167.

Problem Statement

Write a Java applet that responds to a click on a button by displaying a randomly constructed sentence of the form "man bites dog". I.e. noun verb noun.

Outline

Donload the basic skeleton for the Sentence applet. You need two files for an applet. One is a class file that contains the bytecodes for the applet itself. The other is an html file that contains an <APPLET tag that mentions the class file. You will have to write the html file according to the outline on pages 163, 164 of the textbook. You will also have to complete the applet skeleton to perform the sentence task.

The design

Applets are typically only one class, although they can use other classes as long as the browser (appletviewer) knows where to find the other classes. This simple applet will only be one class, called Sentence.

Generating a sentence

Use the Random class to generate random integers that can be used to index an constant array of strings. Use a StringBuffer to hold the sentence you make, and then insert it into the TextField that will be displayed in your applet.

Input

Your applet will respond to a mouse click on the button in the action method as shown in the skeleton.

Output

Your program should display a different sentence every time you click the "next" button.

Deliverables

  1. The source code, with good layout and comments
  2. Mail your source code to the grader, login hhuang.

Due date

October 10th. 1997 before 5:00pm.