Applet details, Variables

Tom Kelliher, CS 116

Sept. 9, 2002

Administrivia

Announcements

Postlabs due when?

Assignment

From Last Time

Lab 2.

Outline

  1. Applet methods.

  2. Variables.

  3. Exercise.

Coming Up

Applet Methods

  1. public void init() { ... } is executed exactly one time when an applet is first created. It is commonly used for setting the colors in the applet and adding the widgets into the applet.

  2. public void paint(Graphics g) { ... } is executed every time the applet needs to be redrawn on the screen.

Variables

  1. Local variables are declared inside a method and can only be used inside that method.

  2. Instance variables are declared outside of the class methods and can be used in any of the methods.

  3. Class variables are declared with the keyword static and are part of the class rather than part of an object. They are used by:
    ClassName.variableName
    

Exercise with Variables



Thomas P. Kelliher
Thu Sep 5 07:34:21 EDT 2002
Tom Kelliher