Using AWT Controls, Layout
Managers, and Menus
his chapter continues our exploration of the Abstract Window Toolkit (AWT). It
begins with an examination of the standard controls and layout managers. It then
discusses menus and the menu bar. The chapter also includes a discussion of two
high-level components: the dialog box and the file dialog box. It concludes with another
look at event handling.
Controls are components that allow a user to interact with your application in various
ways--for example, a commonly used control is the push button. A layout manager
automatically positions components within a container. Thus, the appearance of a window
is determined by a combination of the controls that it contains and the layout manager used
to position them.
In addition to the controls, a frame window can also include a standard-style menu bar.
Each entry in a menu bar activates a drop-down menu of options from which the user can
choose. A menu bar is always positioned at the top of a window. Although different in
appearance, menu bars are handled in much the same way as are the other controls.
While it is possible to manually position components within a window, doing so is quite
tedious. The layout manager automates this task. For the first part of this chapter, which
introduces the various controls, the default layout manager will be used. This displays
components in a container using left-to-right, top-to-bottom organization. Once the controls
have been covered, the layout managers will be examined. There you will see how to better
manage the positioning of your controls.
Control Fundamentals
The AWT supports the following types of controls:
Push buttons
Check boxes
Choice lists
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks