#

| Chapter 18 The java.awt Package |

## 18.16 java.awt.Container (JDK 1.0)

###

This class implements a component that can contain other components. You cannot instantiate `Container` directly, but must use one of its subclasses, such as `Panel`, `Frame`, or `Dialog`. Once a `Container` is created, you may set its `LayoutManager` with `setLayout()`, add components to it with `add()`, and remove them with `remove()`. `getComponents()` returns an array of the components contained in a `Container`. `locate()` determines within which contained component a specified point falls. `list()` produces helpful debugging output.

    public abstract class Container extends Component {
        // Protected Constructor
            1.1  protected Container();
        // Public Instance Methods
                public Component add(Component comp);
                public Component add(String name, Component comp);
                public Component add(Component comp, int index);
            1.1  public void add(Component comp, Object constraints);
            1.1  public void add(Component comp, Object constraints, int index);
            1.1  public void addContainerListener(ContainerListener l);
                public void addNotify();  // Overrides Component
            #   public int countComponents();
            #   public void deliverEvent(Event e);  // Overrides Component
            1.1  public void doLayout();  // Overrides Component
            1.1  public float getAlignmentX();  // Overrides Component
            1.1  public float getAlignmentY();  // Overrides Component
                public Component getComponent(int n);
            1.1  public Component getComponentAt(int x, int y);  // Overrides Component
            1.1  public Component getComponentAt(Point p);  // Overrides Component
            1.1  public int getComponentCount();
                public Component[] getComponents();
            1.1  public Insets getInsets();
                public LayoutManager getLayout();
            1.1  public Dimension getMaximumSize();  // Overrides Component
            1.1  public Dimension getMinimumSize();  // Overrides Component
            1.1  public Dimension getPreferredSize();  // Overrides Component
            #   public Insets insets();
            1.1  public void invalidate();  // Overrides Component
            1.1  public boolean isAncestorOf(Component c);
            #   public void layout();  // Overrides Component
                public void list(PrintStream out, int indent);  // Overrides Component
            1.1  public void list(PrintWriter out, int indent);  // Overrides Component
            #   public Component locate(int x, int y);  // Overrides Component
            #   public Dimension minimumSize();  // Overrides Component
            1.1  public void paint(Graphics g);  // Overrides Component
                public void paintComponents(Graphics g);
            #   public Dimension preferredSize();  // Overrides Component
            1.1  public void print(Graphics g);  // Overrides Component
                public void printComponents(Graphics g);
            1.1  public void remove(int index);
                public void remove(Component comp);
                public void removeAll();
            1.1  public void removeContainerListener(ContainerListener l);
                public void removeNotify();  // Overrides Component
                public void setLayout(LayoutManager mgr);
                public void validate();  // Overrides Component
        // Protected Instance Methods
            1.1  protected void addImpl(Component comp, Object constraints, int index);
                protected String paramString();  // Overrides Component
            1.1  protected void processContainerEvent(ContainerEvent e);
            1.1  protected void processEvent(AWTEvent e);  // Overrides Component
            1.1  protected void validateTree();
    }

### Hierarchy:

`Object->Component(ImageObserver, MenuContainer, Serializable)->Container`

### Extended By:

`Panel, ScrollPane, Window`

### Passed To:

`BorderLayout.getLayoutAlignmentX(), BorderLayout.getLayoutAlignmentY(), BorderLayout.invalidateLayout(), BorderLayout.layoutContainer(), BorderLayout.maximumLayoutSize(), BorderLayout.minimumLayoutSize(), BorderLayout.preferredLayoutSize(), CardLayout.first(), CardLayout.getLayoutAlignmentX(), CardLayout.getLayoutAlignmentY(), CardLayout.invalidateLayout(), CardLayout.last(), CardLayout.layoutContainer(), CardLayout.maximumLayoutSize(), CardLayout.minimumLayoutSize(), CardLayout.next(), CardLayout.preferredLayoutSize(), CardLayout.previous(), CardLayout.show(), FlowLayout.layoutContainer(), FlowLayout.minimumLayoutSize(), FlowLayout.preferredLayoutSize(), GridBagLayout.ArrangeGrid(), GridBagLayout.getLayoutAlignmentX(), GridBagLayout.getLayoutAlignmentY(), GridBagLayout.GetLayoutInfo(), GridBagLayout.GetMinSize(), GridBagLayout.invalidateLayout(), GridBagLayout.layoutContainer(), GridBagLayout.maximumLayoutSize(), GridBagLayout.minimumLayoutSize(), GridBagLayout.preferredLayoutSize(), GridLayout.layoutContainer(), GridLayout.minimumLayoutSize(), GridLayout.preferredLayoutSize(), LayoutManager.layoutContainer(), LayoutManager.minimumLayoutSize(), LayoutManager.preferredLayoutSize(), LayoutManager2.getLayoutAlignmentX(), LayoutManager2.getLayoutAlignmentY(), LayoutManager2.invalidateLayout(), LayoutManager2.maximumLayoutSize()`

### Returned By:

`Component.getParent(), ContainerEvent.getContainer(), Toolkit.getNativeContainer()`

java.awt.Component (JDK 1.0) |  | java.awt.Cursor (JDK 1.1)