Containers
The basic idea in creating a GUI is to start with the components, add the
container(s), then decide upon the layout. See the chapters on the last two
items for additional information. Some examples are presented in the GUIs
chapter.
Java relies heavily on inheritance and interfaces. In order to understand the
concepts it is useful to consider the hierarchy. An abbreviated package
structure is presented below. A dotted line indicates inheritance. Note that
only a partial listing of classes (those used in this course)
are listed.
Note that since javax Components inherit from java containers, javax
Components are also Containers. This allows the user to create some very
sophisticated arrangements.
Only the containers in javax.swing are addressed below. As with the components,
only those that are specifically addressed in this course are included.
Inheritance diagrams (inheritance denoted by solid red lines) are listed,
followed by a summary of uses-capabilities.
JFrame

JPanel, JScrollPane

JApplet

Container
|
Description
|
JFrame
|
Container used for top-level containers in Swing
|
JPanel
|
A generic container for grouping Swing components. Typically used with
an appropriate Layout Manager
|
JScrollPane
|
A container that allows a single child component to be scrolled
horizontally or vertically.
|
JApplet
|
Contains a JRootPane to add Swing features, such as support for
menu bars to applets.
|