Package net.miginfocom.swing
Class MigLayout
- java.lang.Object
-
- net.miginfocom.swing.MigLayout
-
- All Implemented Interfaces:
java.awt.LayoutManager
,java.awt.LayoutManager2
,java.io.Externalizable
,java.io.Serializable
public final class MigLayout extends java.lang.Object implements java.awt.LayoutManager2, java.io.Externalizable
A very flexible layout manager.Read the documentation that came with this layout manager for information on usage.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MigLayout()
Constructor with no constraints.MigLayout(java.lang.String layoutConstraints)
Constructor.MigLayout(java.lang.String layoutConstraints, java.lang.String colConstraints)
Constructor.MigLayout(java.lang.String layoutConstraints, java.lang.String colConstraints, java.lang.String rowConstraints)
Constructor.MigLayout(LC layoutConstraints)
Constructor.MigLayout(LC layoutConstraints, AC colConstraints)
Constructor.MigLayout(LC layoutConstraints, AC colConstraints, AC rowConstraints)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods 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(java.awt.Component comp, java.lang.Object constraints)
void
addLayoutComponent(java.lang.String s, java.awt.Component comp)
java.lang.Object
getColumnConstraints()
Returns the column layout constraints either as aString
orAC
.java.lang.Object
getComponentConstraints(java.awt.Component comp)
Returns the component constraints as a String representation.java.util.Map<java.awt.Component,java.lang.Object>
getConstraintMap()
Returns a shallow copy of the constraints map.float
getLayoutAlignmentX(java.awt.Container parent)
float
getLayoutAlignmentY(java.awt.Container parent)
java.lang.Object
getLayoutConstraints()
Returns layout constraints either as aString
orLC
depending what was sent in to the constructor or set withsetLayoutConstraints(Object)
.java.lang.Object
getRowConstraints()
Returns the row layout constraints either as aString
orAC
.void
invalidateLayout(java.awt.Container target)
boolean
isManagingComponent(java.awt.Component c)
Returns if this layout manager is currently managing this component.void
layoutContainer(java.awt.Container parent)
java.awt.Dimension
maximumLayoutSize(java.awt.Container parent)
java.awt.Dimension
minimumLayoutSize(java.awt.Container parent)
java.awt.Dimension
preferredLayoutSize(java.awt.Container parent)
void
readExternal(java.io.ObjectInput in)
void
removeLayoutCallback(LayoutCallback callback)
Removes the callback if it exists.void
removeLayoutComponent(java.awt.Component comp)
void
setColumnConstraints(java.lang.Object constr)
Sets the column layout constraints for the layout manager instance as a String.void
setComponentConstraints(java.awt.Component comp, java.lang.Object constr)
Sets the component constraint for the component that already must be handled by this layout manager.void
setConstraintMap(java.util.Map<java.awt.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.void
writeExternal(java.io.ObjectOutput out)
-
-
-
Constructor Detail
-
MigLayout
public MigLayout()
Constructor with no constraints.
-
MigLayout
public MigLayout(java.lang.String layoutConstraints)
Constructor.- Parameters:
layoutConstraints
- The constraints that concern the whole layout.null
will be treated as "".
-
MigLayout
public MigLayout(java.lang.String layoutConstraints, java.lang.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(java.lang.String layoutConstraints, java.lang.String colConstraints, java.lang.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 constraint.
-
MigLayout
public MigLayout(LC layoutConstraints, AC colConstraints)
Constructor.- Parameters:
layoutConstraints
- The constraints that concern the whole layout.null
will be treated as an empty constraint.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 constraint.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
-
getLayoutConstraints
public java.lang.Object getLayoutConstraints()
Returns layout constraints either as aString
orLC
depending what was sent in to the constructor or set withsetLayoutConstraints(Object)
.- Returns:
- The layout constraints either as a
String
orLC
depending what was sent in to the constructor or set withsetLayoutConstraints(Object)
. Nevernull
.
-
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
- The layout constraints as a String prLC
representation.null
is converted to""
for storage.- Throws:
java.lang.RuntimeException
- if the constraint was not valid.
-
getColumnConstraints
public java.lang.Object getColumnConstraints()
Returns the column layout constraints either as aString
orAC
.- Returns:
- The column constraints either as a
String
orAC
depending what was sent in to the constructor or set withsetColumnConstraints(Object)
. Nevernull
.
-
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
- The column layout constraints as a String orAC
representation.null
is converted to""
for storage.- Throws:
java.lang.RuntimeException
- if the constraint was not valid.
-
getRowConstraints
public java.lang.Object getRowConstraints()
Returns the row layout constraints either as aString
orAC
.- Returns:
- The row constraints either as a
String
orAC
depending what was sent in to the constructor or set withsetRowConstraints(Object)
. Nevernull
.
-
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
- The row layout constraints as a String orAC
representation.null
is converted to""
for storage.- Throws:
java.lang.RuntimeException
- if the constraint was not valid.
-
getConstraintMap
public java.util.Map<java.awt.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(java.util.Map<java.awt.Component,java.lang.Object> map)
Sets the constraints map.- Parameters:
map
- The map. Will be copied.
-
getComponentConstraints
public java.lang.Object getComponentConstraints(java.awt.Component comp)
Returns the component constraints as a String representation. This string is the exact string as set withsetComponentConstraints(java.awt.Component, 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:
- 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 aCC
depending on what constraint was sent in when the component was added. May benull
.
-
setComponentConstraints
public void setComponentConstraints(java.awt.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
- The component constraints as a String orCC
.null
is ok.comp
- The component to set the constraints for.- Throws:
java.lang.RuntimeException
- if the constraint was not valid.java.lang.IllegalArgumentException
- If the component is not handling the component.
-
isManagingComponent
public boolean isManagingComponent(java.awt.Component c)
Returns if this layout manager is currently managing this component.- Parameters:
c
- The component to check. Ifnull
thenfalse
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. Notnull
.
-
removeLayoutCallback
public void removeLayoutCallback(LayoutCallback callback)
Removes the callback if it exists.- Parameters:
callback
- The callback. May benull
.
-
layoutContainer
public void layoutContainer(java.awt.Container parent)
- Specified by:
layoutContainer
in interfacejava.awt.LayoutManager
-
minimumLayoutSize
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
- Specified by:
minimumLayoutSize
in interfacejava.awt.LayoutManager
-
preferredLayoutSize
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
- Specified by:
preferredLayoutSize
in interfacejava.awt.LayoutManager
-
maximumLayoutSize
public java.awt.Dimension maximumLayoutSize(java.awt.Container parent)
- Specified by:
maximumLayoutSize
in interfacejava.awt.LayoutManager2
-
getLayoutAlignmentX
public float getLayoutAlignmentX(java.awt.Container parent)
- Specified by:
getLayoutAlignmentX
in interfacejava.awt.LayoutManager2
-
getLayoutAlignmentY
public float getLayoutAlignmentY(java.awt.Container parent)
- Specified by:
getLayoutAlignmentY
in interfacejava.awt.LayoutManager2
-
addLayoutComponent
public void addLayoutComponent(java.lang.String s, java.awt.Component comp)
- Specified by:
addLayoutComponent
in interfacejava.awt.LayoutManager
-
addLayoutComponent
public void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
- Specified by:
addLayoutComponent
in interfacejava.awt.LayoutManager2
-
removeLayoutComponent
public void removeLayoutComponent(java.awt.Component comp)
- Specified by:
removeLayoutComponent
in interfacejava.awt.LayoutManager
-
invalidateLayout
public void invalidateLayout(java.awt.Container target)
- Specified by:
invalidateLayout
in interfacejava.awt.LayoutManager2
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
-