# Class MigLayout

java.lang.Object
com.codename1.ui.layouts.Layout
com.codename1.ui.layouts.mig.MigLayout

public final class MigLayout extends Layout

A very flexible layout manager.

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

##### Deprecated

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MigLayout()`
  Constructor with no constraints.
  `MigLayout(LC layoutConstraints)`
  Constructor.
  `MigLayout(LC layoutConstraints, AC colConstraints)`
  Constructor.
  `MigLayout(LC layoutConstraints, AC colConstraints, AC rowConstraints)`
  Constructor.
  `MigLayout(String layoutConstraints)`
  Constructor.
  `MigLayout(String layoutConstraints, String colConstraints)`
  Constructor.
  `MigLayout(String layoutConstraints, String colConstraints, String rowConstraints)`
  Constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addLayoutCallback(LayoutCallback callback)`
  Adds the callback function that will be called at different stages of the layout cylce.
  `void`
  `addLayoutComponent(Component comp, java.lang.Object constraints)`
  `void`
  `addLayoutComponent(java.lang.Object value, Component comp, Container c)`
  Some layouts can optionally track the addition of elements with meta-data that allows the user to "hint" on object positioning.
  `static <E> E`
  `findType(java.lang.Class<E> clazz, Component comp)`
  `java.lang.Object`
  `getColumnConstraints()`
  Returns the column layout constraints either as a `String` or `net.miginfocom.layout.AC`.
  `java.lang.Object`
  `getComponentConstraint(Component comp)`
  Returns the optional component constraint
  `java.lang.Object`
  `getComponentConstraints(Component comp)`
  Returns the component constraints as a String representation.
  `Map<Component, java.lang.Object>`
  `getConstraintMap()`
  Returns a shallow copy of the constraints map.
  `float`
  `getLayoutAlignmentX(Container parent)`
  `float`
  `getLayoutAlignmentY(Container parent)`
  `java.lang.Object`
  `getLayoutConstraints()`
  Returns layout constraints either as a `String` or `net.miginfocom.layout.LC` depending what was sent in to the constructor or set with `#setLayoutConstraints(Object)`.
  `Dimension`
  `getPreferredSize(Container parent)`
  Returns the container preferred size
  `java.lang.Object`
  `getRowConstraints()`
  Returns the row layout constraints either as a `String` or `net.miginfocom.layout.AC`.
  `void`
  `invalidateLayout(Container target)`
  `boolean`
  `isConstraintTracking()`
  If this method returns true, the addLayoutComponent method will be called when replacing a layout for every component within the container
  `boolean`
  `isManagingComponent(Component c)`
  Returns if this layout manager is currently managing this component.
  `void`
  `layoutContainer(Container parent)`
  Layout the given parent container children
  `Dimension`
  `maximumLayoutSize(Container parent)`
  `Dimension`
  `minimumLayoutSize(Container parent)`
  Checks the parent window/popup if its size is within parameters as set by the LC.
  `Dimension`
  `preferredLayoutSize(Container parent)`
  `void`
  `removeLayoutCallback(LayoutCallback callback)`
  Removes the callback if it exists.
  `void`
  `removeLayoutComponent(Component comp)`
  Removes the component from the layout this operation is only useful if the layout maintains references to components within it
  `void`
  `setColumnConstraints(java.lang.Object constr)`
  Sets the column layout constraints for the layout manager instance as a String.
  `void`
  `setComponentConstraints(Component comp, java.lang.Object constr)`
  Sets the component constraint for the component that already must be handled by this layout manager.
  `void`
  `setConstraintMap(Map<Component, java.lang.Object> map)`
  Sets the constraints map.
  `void`
  `setLayoutConstraints(java.lang.Object constr)`
  Sets the layout constraints for the layout manager instance as a String.
  `void`
  `setRowConstraints(java.lang.Object constr)`
  Sets the row layout constraints for the layout manager instance as a String.

  ### Methods inherited from class Layout

  `cloneConstraint, equals, getChildrenInTraversalOrder, hashCode, isOverlapSupported, obscuresPotential, overridesTabIndices, updateTabIndices`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MigLayout

    public MigLayout()
    Constructor with no constraints.

  - ### MigLayout

    public MigLayout(String layoutConstraints)

    Constructor.

    ###### Parameters

    - `layoutConstraints`: @param layoutConstraints The constraints that concern the whole layout. `null` will be treated as "".

  - ### MigLayout

    public MigLayout(String layoutConstraints, String colConstraints)

    Constructor.

    ###### Parameters

    - `layoutConstraints`: @param layoutConstraints The constraints that concern the whole layout. `null` will be treated as "".

    - `colConstraints`: @param 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`: @param layoutConstraints The constraints that concern the whole layout. `null` will be treated as "".

    - `colConstraints`: @param colConstraints The constraints for the columns in the grid. `null` will be treated as "".

    - `rowConstraints`: @param rowConstraints The constraints for the rows in the grid. `null` will be treated as "".

  - ### MigLayout

    public MigLayout(LC layoutConstraints)

    Constructor.

    ###### Parameters

    - `layoutConstraints`: @param layoutConstraints The constraints that concern the whole layout. `null` will be treated as an empty constraint.

  - ### MigLayout

    public MigLayout(LC layoutConstraints, AC colConstraints)

    Constructor.

    ###### Parameters

    - `layoutConstraints`: @param layoutConstraints The constraints that concern the whole layout. `null` will be treated as an empty constraint.

    - `colConstraints`: @param 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`: @param layoutConstraints The constraints that concern the whole layout. `null` will be treated as an empty constraint.

    - `colConstraints`: @param colConstraints The constraints for the columns in the grid. `null` will be treated as an empty constraint.

    - `rowConstraints`: @param rowConstraints The constraints for the rows in the grid. `null` will be treated as an empty constraint.

- ## Method Details

  - ### findType

    public static <E> E findType(java.lang.Class<E> clazz, Component comp)

  - ### getLayoutConstraints

    public java.lang.Object getLayoutConstraints()

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

    ###### Returns

    Returns:
      The layout constraints either as a `String` or `net.miginfocom.layout.LC` depending what was sent in to the constructor or set with `#setLayoutConstraints(Object)`. Never `null`.

  - ### setLayoutConstraints

    public void setLayoutConstraints(java.lang.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`: @param constr The layout constraints as a String pr `net.miginfocom.layout.LC` representation. `null` is converted to `""` for storage.

    ###### Throws

    - `RuntimeException`: if the constraint was not valid.

  - ### getColumnConstraints

    public java.lang.Object getColumnConstraints()

    Returns the column layout constraints either as a `String` or `net.miginfocom.layout.AC`.

    ###### Returns

    Returns:
      The column constraints either as a `String` or `net.miginfocom.layout.AC` depending what was sent in to the constructor or set with `#setColumnConstraints(Object)`. Never `null`.

  - ### setColumnConstraints

    public void setColumnConstraints(java.lang.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`: @param constr The column layout constraints as a String or `net.miginfocom.layout.AC` representation. `null` is converted to `""` for storage.

    ###### Throws

    - `RuntimeException`: if the constraint was not valid.

  - ### getRowConstraints

    public java.lang.Object getRowConstraints()

    Returns the row layout constraints either as a `String` or `net.miginfocom.layout.AC`.

    ###### Returns

    Returns:
      The row constraints either as a `String` or `net.miginfocom.layout.AC` depending what was sent in to the constructor or set with `#setRowConstraints(Object)`. Never `null`.

  - ### setRowConstraints

    public void setRowConstraints(java.lang.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`: @param constr The row layout constraints as a String or `net.miginfocom.layout.AC` representation. `null` is converted to `""` for storage.

    ###### Throws

    - `RuntimeException`: if the constraint was not valid.

  - ### getConstraintMap

    public Map<Component, java.lang.Object> getConstraintMap()

    Returns a shallow copy of the constraints map.

    ###### Returns

    A shallow copy of the constraints map. Never `null`.

  - ### setConstraintMap

    public void setConstraintMap(Map<Component, java.lang.Object> map)

    Sets the constraints map.

    ###### Parameters

    - `map`: The map. Will be copied.

  - ### getComponentConstraints

    public java.lang.Object getComponentConstraints(Component comp)

    Returns the component constraints as a String representation. This string is the exact string as set with `Object)` 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

    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 `net.miginfocom.layout.CC` depending on what constraint was sent in when the component was added. May be `null`.

  - ### setComponentConstraints

    public void setComponentConstraints(Component comp, java.lang.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`: @param constr The component constraints as a String or `net.miginfocom.layout.CC`. `null` is ok.

    - `comp`: The component to set the constraints for.

    ###### Throws

    - `RuntimeException`: if the constraint was not valid.

    - `IllegalArgumentException`: @throws IllegalArgumentException If the component is not handling the component.

  - ### isManagingComponent

    public boolean isManagingComponent(Component c)

    Returns if this layout manager is currently managing this component.

    ###### Parameters

    - `c`: @param c The component to check. If `null` then `false` will be returned.

    ###### Returns

    If this layout manager is currently managing this component.

  - ### 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`.

  - ### removeLayoutCallback

    public void removeLayoutCallback(LayoutCallback callback)

    Removes the callback if it exists.

    ###### Parameters

    - `callback`: The callback. May be `null`.

  - ### layoutContainer

    public void layoutContainer(Container parent)
    Description copied from class: `Layout`

    Layout the given parent container children

    ###### Parameters

    - `parent`: the given parent container
    Specified by:
      `layoutContainer` in class `Layout`

  - ### minimumLayoutSize

    public Dimension minimumLayoutSize(Container parent)

    Checks the parent window/popup if its size is within parameters as set by the LC.

    ###### Parameters

    - `parent`: The parent who's window to possibly adjust the size for.

  - ### preferredLayoutSize

    public Dimension preferredLayoutSize(Container parent)

  - ### maximumLayoutSize

    public Dimension maximumLayoutSize(Container parent)

  - ### getLayoutAlignmentX

    public float getLayoutAlignmentX(Container parent)

  - ### getLayoutAlignmentY

    public float getLayoutAlignmentY(Container parent)

  - ### addLayoutComponent

    public void addLayoutComponent(java.lang.Object value, Component comp, Container c)
    Description copied from class: `Layout`

    Some layouts can optionally track the addition of elements with meta-data that allows the user to "hint" on object positioning.

    ###### Parameters

    - `value`: optional meta data information, like alignment orientation

    - `comp`: the added component to the layout

    - `c`: the parent container

    Overrides:
      `addLayoutComponent` in class `Layout`

  - ### addLayoutComponent

    public void addLayoutComponent(Component comp, java.lang.Object constraints)

  - ### isConstraintTracking

    public boolean isConstraintTracking()
    Description copied from class: `Layout`

    If this method returns true, the addLayoutComponent method will be called when replacing a layout for every component within the container

    ###### Returns

    false by default

    Overrides:
      `isConstraintTracking` in class `Layout`

  - ### getComponentConstraint

    public java.lang.Object getComponentConstraint(Component comp)
    Description copied from class: `Layout`

    Returns the optional component constraint

    ###### Parameters

    - `comp`: the component whose constraint should be returned

    ###### Returns

    the optional component constraint

    Overrides:
      `getComponentConstraint` in class `Layout`

  - ### removeLayoutComponent

    public void removeLayoutComponent(Component comp)
    Description copied from class: `Layout`

    Removes the component from the layout this operation is only useful if the layout maintains references to components within it

    ###### Parameters

    - `comp`: the removed component from layout
    Overrides:
      `removeLayoutComponent` in class `Layout`

  - ### invalidateLayout

    public void invalidateLayout(Container target)

  - ### getPreferredSize

    public Dimension getPreferredSize(Container parent)
    Description copied from class: `Layout`

    Returns the container preferred size

    ###### Parameters

    - `parent`: the parent container

    ###### Returns

    the container preferred size

    Specified by:
      `getPreferredSize` in class `Layout`