Active Widgets

Tom Kelliher, CS 116

Sept. 25, 2000

Administrivia

Announcements

Assignment

Section 3.4, Lab 3 handout.

From Last Time

Component class, Label, TextComponent class.

Outline

  1. Active widget overview.

  2. Exercise.

Coming Up

Lab 3.

Active Widgets Overview

The active widgets:

CheckboxGroup

Example:

Checkbox cb1 = new Checkbox();
Checkbox cb2 = new Checkbox();
CheckboxGroup cbGroup = new CheckboxGroup;

// ...

cb1.setCheckboxGroup(cbGroup);
cb2.setCheckboxGroup(cbGroup);

Choice

Example:

Choice flavors = new Choice();
String selectedItem;

// ...

selectedItem = flavors.getSelectedItem();

List

Example:

// Three rows, single-selection mode.
List myList = List(3, false);

Exercise

  1. Study ActiveWidgets.java. Predict both the appearance of the applet and its behavior when you interact with it. Test your prediction be running the applet. The update button will repaint the applet for you.

  2. Create an ActiveWidgets project.

  3. Add some ice cream flavors.

  4. Change the foreground and background colors of the TextField object.

  5. Group the two Checkboxes into a CheckboxGroup and observe the group's behavior. Something ``weird'' happens. What? For how long?

  6. Replace the multiple-selection List with a single-selection List.

  7. Replace the List with a Choice.



Thomas P. Kelliher
Sun Sep 24 17:27:53 EDT 2000
Tom Kelliher