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.
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); }
Component to add.
Constraints on the component.
Called to add an object to a container. This is slightly more generic than LayoutManager's addLayoutComponent(String, Component).
The container to inspect.
A value between 0 and 1.
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.
The container to inspect.
A value between 0 and 1.
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.
The container to invalidate.
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.
The maximum size of target.
The container to inspect.
This method returns the maximum size of target using this layout manager.
BorderLayout, CardLayout, Component, Container, GridBagLayout, Object, String