Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
This section describes intermediate containers -- Swing components that, while not top-level containers, exist solely to contain other components. Technically, menu bars are intermediate containers, but we discuss them elsewhere, in the How to Use Menus section. To use intermediate containers, you should understand the concepts presented in Swing Components and the Containment Hierarchy. You can see all the intermediate containers in the Visual Index to Swing Components.Swing provides several general-purpose intermediate containers:
Panel The most flexible, frequently used intermediate container. Implemented with the JPanel
class, panels add almost no functionality beyond what allJComponent
objects have. They are often used to group components, whether because the components are related or just because grouping them makes layout easier. A panel can use any layout manager, and you can easily give it a border. The content panes of top-level containers are often implemented asJPanel
instances.Scroll Pane Provides scroll bars around a large or growable component. Split Pane Displays two components in a fixed amount of space, letting the user adjust the amount of space devoted to each component. Tabbed Pane Contains multiple components but shows only one at a time. The user can easily switch between components. Tool Bar Holds a group of components (usually buttons) in a row or column, optionally allowing the user to drag the tool bar into different locations. The rest of the Swing intermediate containers are more specialized:
Internal Frame Looks like a frame and has much the same API, but must appear within another window. Layered Pane Provides a third dimension, depth, for positioning components. You specify the position and size of each component. One type of layered pane, a desktop pane, is designed primarily to contain and manage internal frames. Root Pane Provides behind-the-scenes support to top-level containers.
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2001 Sun Microsystems, Inc. All rights reserved.