Site hosted by Angelfire.com: Build your free website today!
 

Top Level Containers

Every program with a Swing GUI must contain at least one top-level Swing container that provides the support that Swing components need to perform their painting and event handling.

There are three top-level Swing containers:

  • JFrame

  • JDialog

  • JApplet (for applets)

Each JFrame object implements a single main window, and each JDialog implements a secondary window (a window that's dependent on another window). Each JApplet object implements an applet's display area within a browser window.

  • To appear onscreen, every GUI component must be part of a containment hierarchy. Each containment hierarchy has a top-level container as its root.

  • Each top-level container has a content pane that, generally speaking, contains the visible components in that top-level container's GUI.

  • You can optionally add a menu bar to a top-level container. The menu bar is positioned within the top-level container, but outside the content pane.

Note

Swing also provides intermediate container (JPanel)-- Swing components that, while not top-level containers, exist solely to contain other components.