Java Reference
In-Depth Information
Using Frames in a Windowed Application
A container is a special Java object that contains other components, such as
user interface controls and other containers. For example, a window is a familiar
container for users. It can hold icons, buttons, frames, and other components.
Java containers defined in the AWT include Windows, Panels, Frames, Canvases,
Dialogs, and ScrollPanes.
The Reservations program will use a Frame container. As previously noted,
a Frame is an AWT component that serves as a container for a collection of graph-
ical AWT components. Figure 5-17 displays the hierarchy of AWT components.
Notice that the Frame class inherits attributes and methods from the Window
class. Similar to a window, a Frame is used in stand-alone applications to create a
window with its own title bars, borders, icons, and Minimize, Maximize, and Close
buttons. Frames also can include menus and use a number of different insertion
point shapes.
AWT
Components
Text
Component
Button
Canvas
Checkbox
Choice
Container
Label
List
Scrollbar
Panel
ScrollPane
Window
TextArea
TextField
Dialog
Frame
File Dialog
FIGURE 5-17
Frames are a powerful feature of the AWT, because you may use Frames to
build stand-alone windowed applications or to create separate windows for
applets, as is the case when running an applet outside the main window of a
Web browser.
A program that uses a Frame needs to use the word, extends, in the class
header. Recall that a program may extend, or build on, a superclass provided by
Java, such as a Frame, or it may extend a programmer-defined class.
 
Search WWH ::




Custom Search