LayoutManager
Home ] Up ] FlowLayout ] [ LayoutManager ] LayoutManager2 ] Components & Containers ] BorderLayout ] GridLayout ] Insets ] Nested Layouts ]

 

 

The LayoutManager Interface

A class that extends from java.awt.Container is responsible for laying out the components that are contained within it.   Such classes delegate the responsibility of how components are laid out to a layout manager.  A layout manager is responsible for:

  • Calculating the preferred and minimum sizes for a container
  • Laying out the components contained in a container.

A layout manager class implements the methods required by the LayoutManager interface:

Method Description
public void addLayoutComponent(String name, 
                               Component comp)
Adds the specified component with the specified name to the layout.
public void removeLayoutComponent(Component comp)
Removes the specified component from the layout.
public Dimension preferredLayoutSize(Container parent)
Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.
public Dimension minimumLayoutSize(Container parent)
Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.
public void layoutContainer(Container parent)
Lays out the container in the specified panel.

FlowLayout and GridLayout (to be described later) implement the LayoutManager interface directly.

 

This page was last modified on 02 October, 2007