[Chapter 19] LayoutManager

#

| Chapter 19 java.awt Reference |

# LayoutManager

## Name

LayoutManager

##

## Description

`LayoutManager` is an interface that defines the responsibilities of an object that wants to lay out `Component`s to the display in a `Container`.

## Interface Definition

    public abstract interface java.awt.LayoutManager {

      // Interface Methods
      public abstract void addLayoutComponent (String name,
          Component component);
      public abstract void layoutContainer (Container target);
      public abstract Dimension minimumLayoutSize (Container target);
      public abstract Dimension preferredLayoutSize (Container target);
      public abstract void removeLayoutComponent (Component component);
    }

## Interface Methods

### addLayoutComponent

#### public abstract void addLayoutComponent (String name, Component component)

Parameters

  name

    Name of component to add.

  component

    Actual component being added.

Description

  Called when you call `Container.add(String, Component)` to add an object to a container.

### layoutContainer

#### public abstract void layoutContainer (Container target)

Parameters

  target

    The container who needs to be redrawn.

Description

  Called when `target` needs to be redrawn.

### minimumLayoutSize

#### public abstract Dimension minimumLayoutSize (Container target)

Parameters

  target

    The container whose size needs to be calculated.

Returns

  Minimum `Dimension o`f the container `target`

Description

  Called when the minimum size of the `target` container needs to be calculated.

### preferredLayoutSize

#### public abstract Dimension preferredLayoutSize (Container target)

Parameters

  target

    The container whose size needs to be calculated.

Returns

  Preferred `Dimension o`f the container `target`

Description

  Called when the preferred size of the `target` container needs to be calculated.

### removeLayoutComponent

#### public abstract void removeLayoutComponent (Component component)

Parameters

  component

    Component to no longer track.

Description

  Called when you call `Container.remove(Component)` to remove a component from the layout.

## See Also

`Component`, `Container`, `FlowLayout`, `GridLayout`, `Object`, `String`

Label |  | LayoutManager2