public final class MigLayout

  1. Object
  2. Layout
  3. MigLayout
Deprecated. this is currently an experimental integration and has known bugs do not rely on this layout for production

A very flexible layout manager.

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

Constructors

public MigLayout()Constructor with no constraints.
public MigLayout(String layoutConstraints)Constructor.
public MigLayout(String layoutConstraints, String colConstraints)Constructor.
public MigLayout(String layoutConstraints, String colConstraints, String rowConstraints)Constructor.
public MigLayout(LC layoutConstraints)Constructor.
public MigLayout(LC layoutConstraints, AC colConstraints)Constructor.
public MigLayout(LC layoutConstraints, AC colConstraints, AC rowConstraints)Constructor.

Methods

public static <E> E findType(Class<E> clazz, Component comp)
public 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).
public void setLayoutConstraints(Object constr)Sets the layout constraints for the layout manager instance as a String.
public Object getColumnConstraints()Returns the column layout constraints either as a String or net.miginfocom.layout.AC.
public void setColumnConstraints(Object constr)Sets the column layout constraints for the layout manager instance as a String.
public Object getRowConstraints()Returns the row layout constraints either as a String or net.miginfocom.layout.AC.
public void setRowConstraints(Object constr)Sets the row layout constraints for the layout manager instance as a String.
public Map<Component, Object> getConstraintMap()Returns a shallow copy of the constraints map.
public void setConstraintMap(Map<Component, Object> map)Sets the constraints map.
public Object getComponentConstraints(Component comp)Returns the component constraints as a String representation.
public void setComponentConstraints(Component comp, Object constr)Sets the component constraint for the component that already must be handled by this layout manager.
public boolean isManagingComponent(Component c)Returns if this layout manager is currently managing this component.
public void addLayoutCallback(LayoutCallback callback)Adds the callback function that will be called at different stages of the layout cylce.
public void removeLayoutCallback(LayoutCallback callback)Removes the callback if it exists.
public void layoutContainer(Container parent)Layout the given parent container children
public Dimension minimumLayoutSize(Container parent)Checks the parent window/popup if its size is within parameters as set by the LC.
public Dimension preferredLayoutSize(Container parent)
public Dimension maximumLayoutSize(Container parent)
public float getLayoutAlignmentX(Container parent)
public float getLayoutAlignmentY(Container parent)
public void addLayoutComponent(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.
public void addLayoutComponent(Component comp, Object constraints)
public boolean isConstraintTracking()If this method returns true, the addLayoutComponent method will be called when replacing a layout for every component within the container
public Object getComponentConstraint(Component comp)Returns the optional component constraint
public void removeLayoutComponent(Component comp)Removes the component from the layout this operation is only useful if the layout maintains references to components within it
public void invalidateLayout(Container target)
public Dimension getPreferredSize(Container parent)Returns the container preferred size

Inherited methods

Constructor details

MigLayout

public MigLayout()
Constructor with no constraints.

MigLayout

public MigLayout(String layoutConstraints)
Constructor.

Parameters

layoutConstraints String
The constraints that concern the whole layout. null will be treated as “”.

MigLayout

public MigLayout(String layoutConstraints, String colConstraints)
Constructor.

Parameters

layoutConstraints String
The constraints that concern the whole layout. null will be treated as “”.
colConstraints String
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 String
The constraints that concern the whole layout. null will be treated as “”.
colConstraints String
The constraints for the columns in the grid. null will be treated as “”.
rowConstraints String
The constraints for the rows in the grid. null will be treated as “”.

MigLayout

public MigLayout(LC layoutConstraints)
Constructor.

Parameters

layoutConstraints LC
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 LC
The constraints that concern the whole layout. null will be treated as an empty constraint.
colConstraints AC
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 LC
The constraints that concern the whole layout. null will be treated as an empty constraint.
colConstraints AC
The constraints for the columns in the grid. null will be treated as an empty constraint.
rowConstraints AC
The constraints for the rows in the grid. null will be treated as an empty constraint.

Method details

findType

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

getLayoutConstraints

public 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

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(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 Object
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 Object getColumnConstraints()
Returns the column layout constraints either as a String or net.miginfocom.layout.AC.

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(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 Object
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 Object getRowConstraints()
Returns the row layout constraints either as a String or net.miginfocom.layout.AC.

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(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 Object
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, 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, Object> map)
Sets the constraints map.

Parameters

map Map<Component, Object>
The map. Will be copied.

getComponentConstraints

public 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 Component
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 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, 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

comp Component
The component to set the constraints for.
constr Object
The component constraints as a String or net.miginfocom.layout.CC. null is ok.

Throws

RuntimeException
if the constraint was not valid.
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 Component
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 LayoutCallback
The callback. Not null.

removeLayoutCallback

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

Parameters

callback LayoutCallback
The callback. May be null.

layoutContainer

public void layoutContainer(Container parent)
Layout the given parent container children

Parameters

parent Container
the given parent container

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Checks the parent window/popup if its size is within parameters as set by the LC.

Parameters

parent Container
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(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.

Parameters

value Object
optional meta data information, like alignment orientation
comp Component
the added component to the layout
c Container
the parent container

addLayoutComponent

public void addLayoutComponent(Component comp, Object constraints)

isConstraintTracking

public boolean isConstraintTracking()
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

getComponentConstraint

public Object getComponentConstraint(Component comp)
Returns the optional component constraint

Parameters

comp Component
the component whose constraint should be returned

Returns

the optional component constraint

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Removes the component from the layout this operation is only useful if the layout maintains references to components within it

Parameters

comp Component
the removed component from layout

invalidateLayout

public void invalidateLayout(Container target)

getPreferredSize

public Dimension getPreferredSize(Container parent)
Returns the container preferred size

Parameters

parent Container
the parent container

Returns

the container preferred size