Exercise 2: Applets

CS 116

Aug. 28, 2002

  1. Create a project named Hello. Within the project, create an applet class named Hello and copy the contents of the file Hello.java on the class home page into the new class.

    Compile the class and run it.

  2. Add another statement to the body of the paint method which displays your name somewhere in the applet.

  3. Look at the documentation for the Graphics class and see if you can draw a Rectangle somewhere in the applet.

  4. Create a Color object in the paint method with any red, green, and blue values that you want (Remember how to do this from lesson 1?). Look up the documentation for the setColor method in the Graphics class. Use this method at the start of paint with your Color object as its argument and see what happens.

Thomas P. Kelliher
Thu Aug 29 17:08:31 EDT 2002
Tom Kelliher