net.miginfocom.swing

Class MigLayout

public final class MigLayout extends Object implements LayoutManager2, Externalizable

A very flexbile layout manager.

Read the documentation that came with this layout manager for information on usage.

Constructor Summary
MigLayout()
Constructor with no constraints.
MigLayout(String layoutConstraints)
Constructor.
MigLayout(String layoutConstraints, String colConstraints)
Constructor.
MigLayout(String layoutConstraints, String colConstraints, String rowConstraints)
Constructor.
MigLayout(LC layoutConstraints)
Constructor.
MigLayout(LC layoutConstraints, AC colConstraints)
Constructor.
MigLayout(LC layoutConstraints, AC colConstraints, AC rowConstraints)
Constructor.
Method Summary
voidaddLayoutCallback(LayoutCallback callback)
Adds the callback function that will be called at different stages of the layout cylce.
voidaddLayoutComponent(String s, Component comp)
voidaddLayoutComponent(Component comp, Object constraints)
ObjectgetColumnConstraints()
Returns the column layout constraints either as a String or AC.
ObjectgetComponentConstraints(Component comp)
Returns the component constraints as a String representation.
Map<Component,Object>getConstraintMap()
Returns a shallow copy of the constraints map.
floatgetLayoutAlignmentX(Container parent)
floatgetLayoutAlignmentY(Container parent)
ObjectgetLayoutConstraints()
Returns layout constraints either as a String or LC depending what was sent in to the constructor or set with setLayoutConstraints.
ObjectgetRowConstraints()
Returns the row layout constraints as a String representation.
voidinvalidateLayout(Container target)
booleanisManagingComponent(Component c)
Returns if this layout manager is currently managing this component.
voidlayoutContainer(Container parent)
DimensionmaximumLayoutSize(Container parent)
DimensionminimumLayoutSize(Container parent)
DimensionpreferredLayoutSize(Container parent)
voidreadExternal(ObjectInput in)
voidremoveLayoutCallback(LayoutCallback callback)
Removes the callback if it exists.
voidremoveLayoutComponent(Component comp)
voidsetColumnConstraints(Object constr)
Sets the column layout constraints for the layout manager instance as a String.
voidsetComponentConstraints(Component comp, Object constr)
Sets the component constraint for the component that already must be handled by this layout manager.
voidsetConstraintMap(Map<Component,Object> map)
Sets the constraints map.
voidsetLayoutConstraints(Object constr)
Sets the layout constraints for the layout manager instance as a String.
voidsetRowConstraints(Object constr)
Sets the row layout constraints for the layout manager instance as a String.
voidwriteExternal(ObjectOutput out)

Constructor Detail

MigLayout

public MigLayout()
Constructor with no constraints.

MigLayout

public MigLayout(String layoutConstraints)
Constructor.

Parameters: layoutConstraints The constraints that concern the whole layout. null will be treated as "".

MigLayout

public MigLayout(String layoutConstraints, String colConstraints)
Constructor.

Parameters: layoutConstraints The constraints that concern the whole layout. null will be treated as "". colConstraints The constraints for the columns in the grid. null will be treated as "".

MigLayout

public MigLayout(String layoutConstraints, String colConstraints, String rowConstraints)
Constructor.

Parameters: layoutConstraints The constraints that concern the whole layout. null will be treated as "". colConstraints The constraints for the columns in the grid. null will be treated as "". rowConstraints The constraints for the rows in the grid. null will be treated as "".

MigLayout

public MigLayout(LC layoutConstraints)
Constructor.

Parameters: layoutConstraints The constraints that concern the whole layout. null will be treated as an empty cosntraint.

MigLayout

public MigLayout(LC layoutConstraints, AC colConstraints)
Constructor.

Parameters: layoutConstraints The constraints that concern the whole layout. null will be treated as an empty cosntraint. colConstraints The constraints for the columns in the grid. null will be treated as an empty constraint.

MigLayout

public MigLayout(LC layoutConstraints, AC colConstraints, AC rowConstraints)
Constructor.

Parameters: layoutConstraints The constraints that concern the whole layout. null will be treated as an empty cosntraint. colConstraints The constraints for the columns in the grid. null will be treated as an empty constraint. rowConstraints The constraints for the rows in the grid. null will be treated as an empty constraint.

Method Detail

addLayoutCallback

public void addLayoutCallback(LayoutCallback callback)
Adds the callback function that will be called at different stages of the layout cylce.

Parameters: callback The callback. Not null.

addLayoutComponent

public void addLayoutComponent(String s, Component comp)

addLayoutComponent

public void addLayoutComponent(Component comp, Object constraints)

getColumnConstraints

public Object getColumnConstraints()
Returns the column layout constraints either as a String or AC.

Returns: The column constraints either as a String or LC depending what was sent in to the constructor or set with setLayoutConstraints. Never null.

getComponentConstraints

public Object getComponentConstraints(Component comp)
Returns the component constraints as a String representation. This string is the exact string as set with MigLayout or set when adding the component to the parent component.

See the class JavaDocs for information on how this string is formatted.

Parameters: comp The component to return the constraints for.

Returns: The component constraints as a String representation or null if the component is not registered with this layout manager. The returned values is either a String or a CC depending on what constraint was sent in when the component was added. May be null.

getConstraintMap

public Map<Component,Object> getConstraintMap()
Returns a shallow copy of the constraints map.

Returns: A shallow copy of the constraints map. Never null.

getLayoutAlignmentX

public float getLayoutAlignmentX(Container parent)

getLayoutAlignmentY

public float getLayoutAlignmentY(Container parent)

getLayoutConstraints

public Object getLayoutConstraints()
Returns layout constraints either as a String or LC depending what was sent in to the constructor or set with setLayoutConstraints.

Returns: The layout constraints either as a String or LC depending what was sent in to the constructor or set with setLayoutConstraints. Never null.

getRowConstraints

public Object getRowConstraints()
Returns the row layout constraints as a String representation. This string is the exact string as set with setRowConstraints or sent into the constructor.

See the class JavaDocs for information on how this string is formatted.

Returns: The row layout constraints as a String representation. Never null.

invalidateLayout

public void invalidateLayout(Container target)

isManagingComponent

public boolean isManagingComponent(Component c)
Returns if this layout manager is currently managing this component.

Parameters: c The component to check. If null then false will be returned.

Returns: If this layout manager is currently managing this component.

layoutContainer

public void layoutContainer(Container parent)

maximumLayoutSize

public Dimension maximumLayoutSize(Container parent)

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)

readExternal

public void readExternal(ObjectInput in)

removeLayoutCallback

public void removeLayoutCallback(LayoutCallback callback)
Removes the callback if it exists.

Parameters: callback The callback. May be null.

removeLayoutComponent

public void removeLayoutComponent(Component comp)

setColumnConstraints

public void setColumnConstraints(Object constr)
Sets the column layout constraints for the layout manager instance as a String.

See the class JavaDocs for information on how this string is formatted.

Parameters: constr The column layout constraints as a String representation. null is converted to "" for storage.

Throws: RuntimeException if the constraint was not valid.

setComponentConstraints

public void setComponentConstraints(Component comp, Object constr)
Sets the component constraint for the component that already must be handled by this layout manager.

See the class JavaDocs for information on how this string is formatted.

Parameters: constr The component constraints as a String or CC. null is ok. comp The component to set the constraints for.

Throws: RuntimeException if the constraint was not valid. IllegalArgumentException If the component is not handlering the component.

setConstraintMap

public void setConstraintMap(Map<Component,Object> map)
Sets the constraints map.

Parameters: map The map. Will be copied.

setLayoutConstraints

public void setLayoutConstraints(Object constr)
Sets the layout constraints for the layout manager instance as a String.

See the class JavaDocs for information on how this string is formatted.

Parameters: constr The layout constraints as a String representation. null is converted to "" for storage.

Throws: RuntimeException if the constraint was not valid.

setRowConstraints

public void setRowConstraints(Object constr)
Sets the row layout constraints for the layout manager instance as a String.

See the class JavaDocs for information on how this string is formatted.

Parameters: constr The row layout constraints as a String representation. null is converted to "" for storage.

Throws: RuntimeException if the constraint was not valid.

writeExternal

public void writeExternal(ObjectOutput out)