java.awt.LayoutManager (JDK 1.0)
This interface defines the methods necessary for a class to be able to arrange Component objects within a Container object. Most programs use one of the existing classes that implements this interface: BorderLayout, CardLayout, FlowLayout, GridBagConstraints, GridBagLayout, or GridLayout.
To define a new class that lays out components, you must implement each of the methods defined by this interface. addLayoutComponent() is called when a component is added to the container. removeLayoutComponent() is called when a component is removed. layoutContainer() should perform the actual positioning of components by setting the size and position of each component in the specified container. minimumLayoutSize() should return the minimum container width and height that the LayoutManager needs in order to lay out its components. preferredLayoutSize() should return the optimal container width and height for the LayoutManager to lay out its components.
In Java 1.1, layout managers should implement the LayoutManager2 interface, which is an extension of this one. Note that a Java applet or application never directly calls any of these LayoutManager methods--the Container object for which the LayoutManager is registered does that.
public abstract interfaceLayoutManager{ //Public Instance Methodspublic abstract voidaddLayoutComponent(Stringname, Componentcomp); public abstract voidlayoutContainer(Containerparent); public abstract DimensionminimumLayoutSize(Containerparent); public abstract DimensionpreferredLayoutSize(Containerparent); public abstract voidremoveLayoutComponent(Componentcomp); }
Extended By:
LayoutManager2
Implemented By:
FlowLayout, GridLayout
Passed To:
Container.setLayout(), Panel(), ScrollPane.setLayout()
Returned By:
Container.getLayout()