What is a Container?

A container is a component which can contain other components inside itself. It is also an instance of a subclass of java.awt.Container. java.awt.Container extends java.awt.Component so containers are themselves components.

In general components are contained in a container. An applet is a container. Other containers include windows, frames, dialogs, and panels. Containers may contain other containers.

Every container has a LayoutManager that determines how different components are positioned within the container.

In short containers contain components. Components are positioned inside the container according to a LayoutManager. Since containers are themselves components, containers may by placed inside other containers. This is really a lot simpler than it sounds. Applets provide a ready-made container and a default LayoutManager, a FlowLayout.

Previous | Next | Top | Cafe au Lait

Copyright 1997, 2006 Elliotte Rusty Harold
Last Modified August 20, 2006