Java AWT

Previous Chapter 19
java.awt Reference
Next
 

LayoutManager2 (New)

Name

LayoutManager2 (New)

[Graphic: Figure from the text]

Description

LayoutManager2 is an extension of LayoutManager. It provides a more generalized way to add components to a container, as well as more sizing and alignment methods.

Interface Definition

public abstract interface java.awt.LayoutManager2
    extends java.awt.LayoutManager {
  
  // Interface Methods
  public abstract void addLayoutComponent (Component comp, 
      Object constraints);
  public abstract float getLayoutAlignmentX(Container target);
  public abstract float getLayoutAlignmentY(Container target);
  public abstract void invalidateLayout(Container target);
  public abstract Dimension maximumLayoutSize(Container target);
}

Interface Methods

addLayoutComponent

public abstract void addLayoutComponent (Component comp, Object constraints)

Parameters

comp

Component to add.

constraints

Constraints on the component.

Description

Called to add an object to a container. This is slightly more generic than LayoutManager's addLayoutComponent(String, Component).

getLayoutAlignmentX

public abstract float getLayoutAlignmentX (Container target)

Parameters

target

The container to inspect.

Returns

A value between 0 and 1.

Description

This method returns the preferred alignment of the given container target. A return value of 0 is left aligned, .5 is centered, and 1 is right aligned.

getLayoutAlignmentY

public abstract float getLayoutAlignmentY (Container target)

Parameters

target

The container to inspect.

Returns

A value between 0 and 1.

Description

This method returns the preferred alignment of the given container target. A return value of 0 is top aligned, .5 is centered, and 1 is bottom aligned.

invalidateLayout

public abstract void invalidateLayout (Container target)

Parameters

target

The container to invalidate.

Description

Sophisticated layout managers may cache information to improve performance. This method can be used to signal the manager to discard any cached information and start fresh.

maximumLayoutSize

public abstract Dimension maximumLayoutSize (Container target)

Returns

The maximum size of target.

Parameters

target

The container to inspect.

Description

This method returns the maximum size of target using this layout manager.

See Also

BorderLayout, CardLayout, Component, Container, GridBagLayout, Object, String


Previous Home Next
LayoutManager Book Index List

Java in a Nutshell Java Language Reference Java AWT Java Fundamental Classes Exploring Java
This HTML Help has been published using the chm2web software.