Previous | Next | Trail Map | Creating a GUI with JFC/Swing | Using Swing Components

Making Top-Level Containers

Before you attempt to use a top-level container, you should read and understand Swing Components and the Containment Hierarchy(in the Creating a User Interface trail). As that section says, programs that use Swing components put the components in containment hierarchies, and each containment hierarchy has a top-level container as its root.

In general, each application has at least one containment hierarchy headed by a frame (JFrame object). Each applet must have a containment hierarchy headed by a JApplet object. Every additional window in an application or applet has its own containment hierarchy, headed by a frame or dialog (JDialog/JOptionPane).


Note: We don't cover another top-level container, JWindow, because it isn't generally useful. It's simply the Swing version of the AWT Window class, which provides a window with no controls or title that is always on top of every other window.

The content pane that's in every top-level container is provided by a reclusive container called the root pane. You generally don't need to know about the root pane to use Swing components.


Previous | Next | Trail Map | Creating a GUI with JFC/Swing | Using Swing Components