Exercise 3: Applets and Variables

CS 116

Sept. 9, 2002

  1. Take a look at the file Lesson3.java from the class home page. Identify all the local and instance variables. Hint: There are three instance variables and one local variable.

  2. Make a project for Lesson3 and run the applet. Try resizing the applet. What happened and why?

  3. Look at the documentation for the Colors class and notice all the class variables like yellow. How do we know that they are class variables? Look at how the color yellow is used in the init() method. See if you can figure out by looking at the documentation for the TextField class how to change the colors of the TextFields. Try it out.

  4. Change the paintText variable to be a local variable in the paint() method rather than an instance variable. What happens when you compile your program and why?



Thomas P. Kelliher
Thu Sep 5 07:39:53 EDT 2002
Tom Kelliher