In Chapter 3 you saw how easy it is to use
the widget classes in the java.awt package to build interesting
looking (if not particularly functional) applets. You can now
create and customize your own buttons, text containers, choice
boxes, labels, and lists. You don't though, have any means of
grouping widgets together into a single complex component.
Neither do you yet have a good way to control their placement
on the screen. In this lab you'll see how to address both
of these problems.
Java
provides us with a variety of container types which can be used
to hold and group widgets, as well as a few layout managers which
help us control how the components and containers in our
applet display on the screen. Once you see how these containers
and layout managers operate, you'll be able to describe
arbitrarily complicated interfaces in a consistent and
platform-independent way.
![]() |
In this lab, you will: | ||
![]() |
Run and experiment with
this chapter's lablet, |
||
![]() |
Practice using Java containers
to arrange the widgets that make up |
||
![]() |
See the effects of using different layout managers on the appearance of this applet. |
||
![]() |
Extend the |
Gigobite
lablet of Chapter 3 and lay out
its widgets so that they keep their orientations when the applet is
resized. For example, since the three labels associated with the
sandwiches, sides,
and drinks
lists should
always be to the immediate left of the lists, you should invent a
LabeledList
class that groups a label and a list together in
one panel.