Class UILayoutConstants
- Direct Known Subclasses:
UIFactoryMethods
MigLayout LayoutManager type. This class is not intended to be instantiated!
The constants as well as static factory methods in this class are intended to be used like this:
import static swingtree.UI.*;
//...
panel(FILL.and(WRAP(2)))
.withPrefSize(500, 300)
.add(GROW,
panel(FILL_X.and(WRAP(2)),"[shrink][grow]")
.add(label("Username"))
.add(GROW_X,
textField(vm.username())
)
.add(SHRINK_X, label("Password"))
.add(GROW_X,
passwordField(vm.password())
)
)
.add(GROW,
panel(FILL_X.and(WRAP(2)),"[shrink][grow]")
.add(label("Email"))
.add(GROW_X,
textField(vm.email())
)
.add(SHRINK_X, label("Gender"))
.add(GROW_X,
comboBox(vm.gender())
)
)
.add(GROW_X,
panel(FILL_X.and(WRAP(1)))
.add(GROW_X,
checkBox("I accept!", vm.termsAccepted())
)
.add(GROW_X,
button("Register")
.onClick( it -> vm.register() )
)
)
.add(GROW_X,
panel(FILL_X.and(WRAP(1)))
.withBorderTitled("Feedback")
.add(GROW_X,
boldLabel(
vm.feedback()
)
.withForeground(vm.feedbackColor())
)
)
.add(GROW_X.and(SPAN), button("RESET").onClick( it -> vm.reset() ));
In this little example form we can see how the constants are used to
create a form with a grid layout. The
FILL constant is used to make the panels fill the entire
width of the parent panel. The
WRAP(int) constant is used to make the panels wrap after
n components have been added to them. The
GROW constant is used to make the panels grow vertically
to fill the entire height of the parent panel. ... and so on.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic MigAddConstraintCentres this component both horizontally and vertically within its cell.static MigAddConstraintPushes this component to the left edge of its cell.static MigAddConstraintPushes this component to the right edge of its cell.static MigAddConstraintCentres this component horizontally within its cell, without affecting its vertical position.static MigAddConstraintPushes this component to the left edge of its cell (horizontal axis only).static MigAddConstraintPushes this component to the right edge of its cell (horizontal axis only).static MigAddConstraintPushes this component to the bottom edge of its cell (vertical axis only).static MigAddConstraintCentres this component vertically within its cell, without affecting its horizontal position.static MigAddConstraintPushes this component to the top edge of its cell (vertical axis only).static MigAddConstraintShorthand to align this component at the bottom of its cell.static MigAddConstraintShorthand to centre this component in its cell (both axes).static LayoutConstraintTurns on visual debug painting for the container.static MigAddConstraintDocks this component against the right edge of the container.static MigAddConstraintDocks this component against the top edge of the container.static MigAddConstraintDocks this component against the bottom edge of the container.static MigAddConstraintDocks this component against the left edge of the container.static LayoutConstraintMakes the layout claim all available space in the container for both columns and rows.static LayoutConstraintMakes the layout claim all available horizontal space in the container for its columns.static LayoutConstraintMakes the layout claim all available vertical space in the container for its rows.static LayoutConstraintSets the layout's flow direction to horizontal (left to right).static LayoutConstraintSets the layout's flow direction to vertical (top to bottom).static MigAddConstraintAdds an expanding (pushing) gap below this component.static MigAddConstraintAdds an expanding (pushing) gap to the left of this component.static MigAddConstraintAdds an expanding (pushing) gap to the right of this component.static MigAddConstraintAdds an expanding (pushing) gap above this component.static MigAddConstraintTells this component to eagerly expand in both directions to fill any extra space in its cell.static MigAddConstraintTells this component to eagerly expand horizontally to fill any extra width in its cell.static MigAddConstraintTells this component to eagerly expand vertically to fill any extra height in its cell.static MigAddConstraintShorthand to align this component at the left of its cell.static LayoutConstraintTells the layout engine to skip its internal caching.static LayoutConstraintDisables the grid entirely and puts the layout into flow-only mode.static MigAddConstraintMakes the row and column that this component sits in greedily absorb all leftover space in the container.static MigAddConstraintMakes the column that this component sits in greedily absorb all leftover horizontal space.static MigAddConstraintMakes the row that this component sits in greedily absorb all leftover vertical space.static MigAddConstraintShorthand to align this component at the right of its cell.static MigAddConstraintAllows this component to shrink in both directions when the container is too small to fit everything at preferred size.static MigAddConstraintAllows this component to shrink horizontally when the container is too narrow to fit everything at preferred width.static MigAddConstraintAllows this component to shrink vertically when the container is too short to fit everything at preferred height.static MigAddConstraintMakes this component span across all remaining columns in the current row.static MigAddConstraintShorthand to align this component at the top of its cell.static MigAddConstraintA component-level constraint that tells the layout to break to a new row after this component. -
Method Summary
Modifier and TypeMethodDescriptionstatic net.miginfocom.layout.ACAC()A factory method for creating anAC(Axis Constraints) instance.static MigAddConstraintAligns this component within its cell according to the givenUI.Side.static FlowCellAUTO_SPAN(int numberOfCells) A factory method for creating aFlowCellinstance that will span the given number of cells for each parent size category when used in aResponsiveGridFlowLayoutlayout.static FlowCellAUTO_SPAN(Configurator<FlowCellConf> configurator) A factory method for creating anAddConstraintof theFlowCelltype, that is used to define at which parent size category how many cells the component should span as part of aResponsiveGridFlowLayoutlayout configuration.static net.miginfocom.layout.CCCC()A factory method for creating aCC(Component Constraints) instance.static MigAddConstraintDocks this component against the edge of the container indicated by the givenUI.Side.static MigAddConstraintGAP_BOTTOM(int size) Adds a fixed-size gap below this component.static MigAddConstraintGAP_LEFT(int size) Adds a fixed-size gap to the left of this component.static LayoutConstraintGAP_REL(int size) Sets the default gap between grid cells to a platform-relative size.static MigAddConstraintGAP_RIGHT(int size) Adds a fixed-size gap to the right of this component.static MigAddConstraintGAP_TOP(int size) Adds a fixed-size gap above this component.static MigAddConstraintGROW(int weight) Tells this component to grow in both directions with a specific weight.static MigAddConstraintGROW_X(int weight) Tells this component to grow horizontally with a specific weight.static MigAddConstraintGROW_Y(int weight) Tells this component to grow vertically with a specific weight.static MigAddConstraintHEIGHT(int min, int pref, int max) Overrides this component's height with explicit minimum, preferred, and maximum values (in pixels).static LayoutConstraintINS(int insets) Shorthand forINSETS(int).static LayoutConstraintINS(int top, int left, int bottom, int right) Shorthand forINSETS(int, int, int, int).static LayoutConstraintINSETS(int insets) Sets uniform inner padding around the entire container content.static LayoutConstraintINSETS(int top, int left, int bottom, int right) Sets individual inner padding for each side of the container.static net.miginfocom.layout.LCLC()A factory method for creating aLCinstance.static MigAddConstraintPAD(int size) Applies uniform padding around this component in absolute pixels.static MigAddConstraintPAD(int top, int left, int bottom, int right) Applies individual padding around this component in absolute pixels.static MigAddConstraintPUSH(int weight) Makes the row and column absorb leftover space with a specific weight.static MigAddConstraintPUSH_X(int weight) Makes the column absorb leftover horizontal space with a specific weight.static MigAddConstraintPUSH_Y(int weight) Makes the row absorb leftover vertical space with a specific weight.static MigAddConstraintSHRINK(int weight) Sets how willingly this component shrinks in both directions relative to its siblings.static MigAddConstraintSHRINK_PRIO(int priority) Sets the shrink priority for this component.static MigAddConstraintSHRINK_X(int weight) Sets how willingly this component shrinks horizontally relative to its siblings when the container is too narrow.static MigAddConstraintSHRINK_Y(int weight) Sets how willingly this component shrinks vertically relative to its siblings when the container is too short.static MigAddConstraintSKIP(int cells) Skips over a number of cells in the grid flow before placing this component.static MigAddConstraintSPAN(int times) Makes this component span acrosstimescolumns in the current row.static MigAddConstraintSPAN(int xTimes, int yTimes) Makes this component span acrossxTimescolumns andyTimesrows, merging a rectangular block of grid cells into one large cell.static MigAddConstraintSPAN_X(int times) Makes this component span acrosstimescolumns only (horizontal direction), without affecting the row span.static MigAddConstraintSPAN_Y(int times) Makes this component span acrosstimesrows only (vertical direction), without affecting the column span.static MigAddConstraintSPLIT(int cells) Splits the current cell intocellssub-slots, so that the nextcellscomponents all share the same grid cell and are placed side by side within it (without gaps between them).static MigAddConstraintWIDTH(int min, int pref, int max) Overrides this component's width with explicit minimum, preferred, and maximum values (in pixels).static LayoutConstraintWRAP(int times) Turns on auto-wrapping so that the layout grid moves to a new row after everytimescomponents.
-
Field Details
-
FILL
Makes the layout claim all available space in the container for both columns and rows. Think of it as the layout stretching out like a rubber sheet to cover the entire container — but individual components will only actually expand if they themselves also have aGROWconstraint applied to them.This is a layout-level constraint, meaning it is passed to the panel factory method (e.g.
UI.panel(FILL)) rather than to.add(..)calls. -
FILL_X
Makes the layout claim all available horizontal space in the container for its columns. Imagine the columns stretching sideways to fill the container's width, while the rows remain only as tall as their content needs. Components still need their ownGROW_Xconstraint to actually widen along with the column.This is a layout-level constraint, meaning it is passed to the panel factory method (e.g.
UI.panel(FILL_X)) rather than to.add(..)calls. -
FILL_Y
Makes the layout claim all available vertical space in the container for its rows. Imagine the rows stretching downward to fill the container's height, while the columns remain only as wide as their content needs. Components still need their ownGROW_Yconstraint to actually grow taller along with the row.This is a layout-level constraint, meaning it is passed to the panel factory method (e.g.
UI.panel(FILL_Y)) rather than to.add(..)calls. -
FLOW_X
Sets the layout's flow direction to horizontal (left to right). This is the default, so you typically only need this to explicitly override a parent's vertical flow or to make your intention clear in code. Components are placed side by side, filling columns first.This is a layout-level constraint.
-
FLOW_Y
Sets the layout's flow direction to vertical (top to bottom). Instead of placing components side by side in a row, each new component is placed below the previous one, filling rows first — like a vertical stack.This is a layout-level constraint.
-
NO_GRID
Disables the grid entirely and puts the layout into flow-only mode. All components are placed in a single row (or column, if vertical flow), one after another, without any column/row alignment. Think of it like a simpleFlowLayout— components just stream in sequence without snapping to a grid.This is a layout-level constraint.
-
NO_CACHE
Tells the layout engine to skip its internal caching. Normally the layout caches calculated sizes for performance, but if you use percentage-based sizing ("%") or experience revalidation glitches, disabling the cache forces a fresh calculation on every layout pass.This is a layout-level constraint. Only use it when you actually observe layout anomalies.
-
DEBUG
Turns on visual debug painting for the container. When active, the layout draws coloured outlines around every grid cell and component boundary, making it easy to see why things ended up where they did. The overlay repaints once per second.This is a layout-level constraint. Remove it before shipping — it is purely a development aid.
-
WRAP
A component-level constraint that tells the layout to break to a new row after this component. It is the per-component equivalent of pressing "Enter" — whatever comes next starts on a fresh row beneath this one.Use this when you don't want global auto-wrapping via
WRAP(int)but need a line break at a specific point. -
SPAN
Makes this component span across all remaining columns in the current row. The component stretches from its current cell all the way to the right edge of the grid, merging every cell it crosses into one wide cell.This is a component-level constraint, passed to
.add(SPAN, ...). -
GROW
Tells this component to eagerly expand in both directions to fill any extra space in its cell. Without this, a component just sits at its preferred size even if the cell around it is larger. WithGROW, it stretches like a balloon to use all available room.Works hand in hand with layout-level
FILLorFILL_X/FILL_Y, which make the cells themselves expand to fill the container.This is a component-level constraint.
-
GROW_X
Tells this component to eagerly expand horizontally to fill any extra width in its cell. The component stretches sideways but keeps its natural height.This is a component-level constraint.
-
GROW_Y
Tells this component to eagerly expand vertically to fill any extra height in its cell. The component stretches downward but keeps its natural width.This is a component-level constraint.
-
SHRINK
Allows this component to shrink in both directions when the container is too small to fit everything at preferred size. By default, all components already have a shrink weight of 100, so they can shrink down to their minimum size. Use this constant explicitly when combining it with other constraints or to make your intent clear.This is a component-level constraint.
-
SHRINK_X
Allows this component to shrink horizontally when the container is too narrow to fit everything at preferred width.This is a component-level constraint.
-
SHRINK_Y
Allows this component to shrink vertically when the container is too short to fit everything at preferred height.This is a component-level constraint.
-
PUSH
Makes the row and column that this component sits in greedily absorb all leftover space in the container. WhileGROWtells the component to fill its cell,PUSHtells the cell's row and column to expand and claim any unclaimed container space. The effect is that surrounding components get pushed toward the container edges.This is a component-level constraint.
-
PUSH_X
Makes the column that this component sits in greedily absorb all leftover horizontal space. Other columns are pushed toward the left and right edges.This is a component-level constraint.
-
PUSH_Y
Makes the row that this component sits in greedily absorb all leftover vertical space. Other rows are pushed toward the top and bottom edges.This is a component-level constraint.
-
ALIGN_CENTER
Centres this component both horizontally and vertically within its cell.This is a component-level constraint.
-
ALIGN_LEFT
Pushes this component to the left edge of its cell.This is a component-level constraint.
-
ALIGN_RIGHT
Pushes this component to the right edge of its cell.This is a component-level constraint.
-
ALIGN_X_CENTER
Centres this component horizontally within its cell, without affecting its vertical position.This is a component-level constraint.
-
ALIGN_X_LEFT
Pushes this component to the left edge of its cell (horizontal axis only).This is a component-level constraint.
-
ALIGN_X_RIGHT
Pushes this component to the right edge of its cell (horizontal axis only).This is a component-level constraint.
-
ALIGN_Y_CENTER
Centres this component vertically within its cell, without affecting its horizontal position.This is a component-level constraint.
-
ALIGN_Y_BOTTOM
Pushes this component to the bottom edge of its cell (vertical axis only).This is a component-level constraint.
-
ALIGN_Y_TOP
Pushes this component to the top edge of its cell (vertical axis only).This is a component-level constraint.
-
TOP
Shorthand to align this component at the top of its cell. Equivalent toALIGN_Y_TOP.This is a component-level constraint.
-
RIGHT
Shorthand to align this component at the right of its cell. Equivalent toALIGN_X_RIGHT.This is a component-level constraint.
-
BOTTOM
Shorthand to align this component at the bottom of its cell. Equivalent toALIGN_Y_BOTTOM.This is a component-level constraint.
-
LEFT
Shorthand to align this component at the left of its cell. Equivalent toALIGN_X_LEFT.This is a component-level constraint.
-
CENTER
Shorthand to centre this component in its cell (both axes). Equivalent toALIGN_CENTER.This is a component-level constraint.
-
GAP_LEFT_PUSH
Adds an expanding (pushing) gap to the left of this component. A pushing gap is greedy: it absorbs all available leftover space, effectively shoving this component to the right. Think of it as an invisible spring pushing from the left.This is a component-level constraint.
-
GAP_RIGHT_PUSH
Adds an expanding (pushing) gap to the right of this component. The gap absorbs all available leftover space, shoving this component to the left.This is a component-level constraint.
-
GAP_TOP_PUSH
Adds an expanding (pushing) gap above this component. The gap absorbs all available leftover space, shoving this component downward.This is a component-level constraint.
-
GAP_BOTTOM_PUSH
Adds an expanding (pushing) gap below this component. The gap absorbs all available leftover space, shoving this component upward.This is a component-level constraint.
-
DOCK_NORTH
Docks this component against the top edge of the container. The component stretches across the full container width and "cuts off" a horizontal strip at the top. Remaining components are laid out in the space below. Works likeBorderLayout.NORTHbut supports multiple docked components stacking in the order they are added.This is a component-level constraint.
-
DOCK_SOUTH
Docks this component against the bottom edge of the container. The component stretches across the full container width and "cuts off" a horizontal strip at the bottom.This is a component-level constraint.
-
DOCK_EAST
Docks this component against the right edge of the container. The component stretches across the full container height (between any north/south docks) and "cuts off" a vertical strip on the right.This is a component-level constraint.
-
DOCK_WEST
Docks this component against the left edge of the container. The component stretches across the full container height (between any north/south docks) and "cuts off" a vertical strip on the left.This is a component-level constraint.
-
-
Method Details
-
INS
Shorthand forINSETS(int). Sets the same padding on all four sides of the container.- Parameters:
insets- The padding size in pixels, applied equally to top, left, bottom, and right.- Returns:
- A layout constraint that adds uniform inner padding around the container's content.
-
INSETS
Sets uniform inner padding around the entire container content. Picture a picture frame: the insets are the space between the frame edge and the picture itself. All four sides get the same padding.This replaces the gap before/after the first/last column and row with the specified value, similar to setting an
EmptyBorderbut without removing any border that is already on the container.This is a layout-level constraint.
- Parameters:
insets- The padding size in pixels, applied equally to top, left, bottom, and right.- Returns:
- A layout constraint that adds uniform inner padding around the container's content.
-
INS
Shorthand forINSETS(int, int, int, int). Sets individual padding for each side of the container.- Parameters:
top- Padding above the content, in pixels.left- Padding to the left of the content, in pixels.bottom- Padding below the content, in pixels.right- Padding to the right of the content, in pixels.- Returns:
- A layout constraint that adds the specified inner padding around the container's content.
-
INSETS
Sets individual inner padding for each side of the container. Like a picture frame with different border widths — you can have more space at the top than the bottom, for example.This replaces the gap before/after the first/last column and row with the specified values, similar to setting an
EmptyBorderbut without removing any border that is already on the container.This is a layout-level constraint.
- Parameters:
top- Padding above the content, in pixels.left- Padding to the left of the content, in pixels.bottom- Padding below the content, in pixels.right- Padding to the right of the content, in pixels.- Returns:
- A layout constraint that adds the specified inner padding around the container's content.
-
WRAP
Turns on auto-wrapping so that the layout grid moves to a new row after everytimescomponents. Think of it like a typewriter carriage return: after placingtimescomponents side by side, the next component drops down to a fresh row.Without this constraint, all components flow into a single row unless individual components carry a
WRAPadd-constraint.This is a layout-level constraint.
- Parameters:
times- The number of components per row before wrapping to the next row.- Returns:
- A layout constraint that enables automatic row wrapping.
-
GAP_REL
Sets the default gap between grid cells to a platform-relative size. Thesizevalue is interpreted as a relative unit, meaning the actual pixel spacing adapts to the platform's look-and-feel conventions. Use this when you want spacing that "feels right" on any operating system rather than a fixed pixel count.This is a layout-level constraint.
- Parameters:
size- The relative gap size.- Returns:
- A layout constraint that sets platform-relative spacing between cells.
-
SPAN
Makes this component span acrosstimescolumns in the current row. The component merges that many consecutive cells into one wider cell, giving it more horizontal room.This is a component-level constraint.
- Parameters:
times- The number of columns to merge into a single cell.- Returns:
- A constraint that widens this component's cell by the given column count.
-
SPAN
Makes this component span acrossxTimescolumns andyTimesrows, merging a rectangular block of grid cells into one large cell. Useful for components that need to occupy a multi-cell area, like a large text area in a form.This is a component-level constraint.
- Parameters:
xTimes- The number of columns to span.yTimes- The number of rows to span.- Returns:
- A constraint that merges columns and rows into a single cell for this component.
-
SPAN_X
Makes this component span acrosstimescolumns only (horizontal direction), without affecting the row span.This is a component-level constraint.
- Parameters:
times- The number of columns to merge.- Returns:
- A constraint that widens the cell horizontally by the given column count.
-
SPAN_Y
Makes this component span acrosstimesrows only (vertical direction), without affecting the column span.This is a component-level constraint.
- Parameters:
times- The number of rows to merge.- Returns:
- A constraint that extends the cell vertically by the given row count.
-
GROW
Tells this component to grow in both directions with a specific weight. The weight is a relative number: a component with weight 200 gets twice as much extra space as one with weight 100. Use this when multiple growing components compete for the same space and you want to control how the surplus is divided.This is a component-level constraint.
- Parameters:
weight- The relative grow weight (default is 100 when usingGROW).- Returns:
- A constraint that makes the component grow with the specified weight.
-
GROW_X
Tells this component to grow horizontally with a specific weight. A higher weight means this component claims a larger share of the available extra width compared to other growing components.This is a component-level constraint.
- Parameters:
weight- The relative horizontal grow weight.- Returns:
- A constraint that makes the component grow horizontally with the specified weight.
-
GROW_Y
Tells this component to grow vertically with a specific weight. A higher weight means this component claims a larger share of the available extra height compared to other growing components.This is a component-level constraint.
- Parameters:
weight- The relative vertical grow weight.- Returns:
- A constraint that makes the component grow vertically with the specified weight.
-
SHRINK
Sets how willingly this component shrinks in both directions relative to its siblings. A component with weight 200 will give up twice as many pixels as one with weight 100 when space gets tight. Think of it as "eagerness to sacrifice space."This is a component-level constraint.
- Parameters:
weight- The relative shrink weight (default is 100).- Returns:
- A constraint that controls how much this component shrinks relative to others.
-
SHRINK_X
Sets how willingly this component shrinks horizontally relative to its siblings when the container is too narrow.This is a component-level constraint.
- Parameters:
weight- The relative horizontal shrink weight.- Returns:
- A constraint controlling horizontal shrink eagerness.
-
SHRINK_Y
Sets how willingly this component shrinks vertically relative to its siblings when the container is too short.This is a component-level constraint.
- Parameters:
weight- The relative vertical shrink weight.- Returns:
- A constraint controlling vertical shrink eagerness.
-
SHRINK_PRIO
Sets the shrink priority for this component. When space is scarce, components with higher priority values are shrunk to their minimum size first, before any lower-priority component is touched. The default priority is 100.Use this to protect important components from shrinking by giving them a low priority, while expendable components get a high priority and absorb the squeeze first.
This is a component-level constraint.
- Parameters:
priority- The shrink priority (higher = shrinks sooner).- Returns:
- A constraint that sets the component's shrink priority.
-
PUSH
Makes the row and column absorb leftover space with a specific weight. When multiple cells push, the weight determines how the leftover space is divided between them — higher weight means a bigger share.This is a component-level constraint.
- Parameters:
weight- The relative push weight.- Returns:
- A constraint that makes the component's row and column push with the given weight.
-
PUSH_X
Makes the column absorb leftover horizontal space with a specific weight.This is a component-level constraint.
- Parameters:
weight- The relative horizontal push weight.- Returns:
- A constraint that makes the column push horizontally with the given weight.
-
PUSH_Y
Makes the row absorb leftover vertical space with a specific weight.This is a component-level constraint.
- Parameters:
weight- The relative vertical push weight.- Returns:
- A constraint that makes the row push vertically with the given weight.
-
SKIP
Skips over a number of cells in the grid flow before placing this component. It is like leaving blank cells in a spreadsheet — the component landscellspositions further along than it normally would.This is a component-level constraint.
- Parameters:
cells- The number of cells to jump over.- Returns:
- A constraint that skips the specified number of grid cells.
-
SPLIT
Splits the current cell intocellssub-slots, so that the nextcellscomponents all share the same grid cell and are placed side by side within it (without gaps between them). Think of it as subdividing a single table cell into smaller compartments.Only the first component placed into a cell may declare the split; subsequent split keywords in the same cell are ignored.
This is a component-level constraint.
- Parameters:
cells- The number of sub-slots to create in this cell.- Returns:
- A constraint that splits the cell for multiple components.
-
WIDTH
Overrides this component's width with explicit minimum, preferred, and maximum values (in pixels). This takes precedence over whatever size the component would normally report.For example,
WIDTH(80, 120, 200)means the component will be at least 80 px wide, ideally 120 px, and never wider than 200 px.This is a component-level constraint.
- Parameters:
min- The minimum width in pixels.pref- The preferred width in pixels.max- The maximum width in pixels.- Returns:
- A constraint that overrides the component's width bounds.
-
HEIGHT
Overrides this component's height with explicit minimum, preferred, and maximum values (in pixels). This takes precedence over whatever size the component would normally report.For example,
HEIGHT(20, 30, 50)means the component will be at least 20 px tall, ideally 30 px, and never taller than 50 px.This is a component-level constraint.
- Parameters:
min- The minimum height in pixels.pref- The preferred height in pixels.max- The maximum height in pixels.- Returns:
- A constraint that overrides the component's height bounds.
-
PAD
Applies uniform padding around this component in absolute pixels. Padding nudges the component's painted bounds outward (or inward, if negative) after the layout has been computed. It does not affect other components' positions or the cell size — it is purely a last-step visual adjustment.For example,
PAD(5)makes the component 10 px wider and 10 px taller (5 px on each side).This is a component-level constraint.
- Parameters:
size- The padding in pixels, applied equally to all four sides.- Returns:
- A constraint that pads the component's bounds.
-
PAD
Applies individual padding around this component in absolute pixels. Each side can have a different value. Positive values push the edge outward; negative values pull it inward. This adjustment happens after layout, so it does not move neighbouring components or change cell sizes.This is a component-level constraint.
- Parameters:
top- Padding above the component, in pixels.left- Padding to the left, in pixels.bottom- Padding below the component, in pixels.right- Padding to the right, in pixels.- Returns:
- A constraint that pads the component's bounds on each side.
-
ALIGN
Aligns this component within its cell according to the givenUI.Side.This is a component-level constraint.
- Parameters:
pos- The side/direction to align toward.- Returns:
- A constraint that aligns the component as specified.
-
GAP_LEFT
Adds a fixed-size gap to the left of this component. The gap is empty space measured in pixels that separates this component from whatever is to its left (another component or the cell edge).This is a component-level constraint.
- Parameters:
size- Gap size in pixels.- Returns:
- A constraint adding a left-side gap.
-
GAP_RIGHT
Adds a fixed-size gap to the right of this component.This is a component-level constraint.
- Parameters:
size- Gap size in pixels.- Returns:
- A constraint adding a right-side gap.
-
GAP_TOP
Adds a fixed-size gap above this component.This is a component-level constraint.
- Parameters:
size- Gap size in pixels.- Returns:
- A constraint adding a top-side gap.
-
GAP_BOTTOM
Adds a fixed-size gap below this component.This is a component-level constraint.
- Parameters:
size- Gap size in pixels.- Returns:
- A constraint adding a bottom-side gap.
-
DOCK
Docks this component against the edge of the container indicated by the givenUI.Side.This is a component-level constraint.
- Parameters:
pos- The side of the container to dock against.- Returns:
- A docking constraint for the specified side.
-
LC
public static net.miginfocom.layout.LC LC()A factory method for creating aLCinstance.- Returns:
- A
LCinstance.
-
AC
public static net.miginfocom.layout.AC AC()A factory method for creating anAC(Axis Constraints) instance. Use this when you need to define column or row constraints programmatically via the MigLayout API rather than as a constraint string. The returned object provides a fluent builder for specifying sizes, gaps, alignments, and grow/shrink behaviour for each column or row in the grid.- Returns:
- A fresh
ACinstance.
-
CC
public static net.miginfocom.layout.CC CC()A factory method for creating aCC(Component Constraints) instance. Use this when you need fine-grained, programmatic control over a single component's placement and sizing — position, span, split, grow, shrink, alignment, gaps, and more — via the MigLayout API rather than as a constraint string.- Returns:
- A fresh
CCinstance.
-
AUTO_SPAN
A factory method for creating anAddConstraintof theFlowCelltype, that is used to define at which parent size category how many cells the component should span as part of aResponsiveGridFlowLayoutlayout configuration.
Here is an example of how this factory method might be used as part of a larger UI declaration:
In the above example, theUI.panel().withFlowLayout() .withPrefSize(400, 300) .add(UI.AUTO_SPAN( it->it.small(12).medium(6).large(8) ), html("A red cell").withStyle(it->it .backgroundColor(UI.Color.RED) ) ) .add(UI.AUTO_SPAN( it->it.small(12).medium(6).large(4) ), html("a green cell").withStyle(it->it .backgroundColor(Color.GREEN) ) )itparameter of theConfiguratoris an instance of theFlowCellConfclass, which defines cell span sizes for different parent size categories.
These parent size categories are determined by the width of the parent container compared to its preferred width.
So a parent is considered larger if its width is closer to its preferred width and smaller if its width is closer to 0.
The
Configuratorpassed to this method is called every time theResponsiveGridFlowLayoutupdates the layout of the parent container. This allows it to determine the number of cells a component should span dynamically at a given size.
If you do not perform any configuration in the supplied configurator, then the component will span 12 cells at all parent sizes.
The
UIForAnySwing.withFlowLayout()creates the necessaryResponsiveGridFlowLayoutand attaches it to the panel.
Note that a
ResponsiveGridFlowLayoutis required for theFlowCellconfiguration to have any effect. TheFlowCellconfiguration is not compatible with other layout managers likeMigLayout.- Parameters:
configurator- AConfiguratorthat configures aFlowCellConfinstance.- Returns:
- An
FlowCellinstance containing the responsive cell span configuration for a component that is part of a parent component with aResponsiveGridFlowLayoutlayout manager.
-
AUTO_SPAN
A factory method for creating aFlowCellinstance that will span the given number of cells for each parent size category when used in aResponsiveGridFlowLayoutlayout.
Here is an example of how this factory method might be used as part of a larger UI declaration:
In the above example, the first cell will always span 12 cells and the second cell will always span 6 cells, regardless of the parent size.UI.panel().withFlowLayout() .withPrefSize(400, 300) .add(UI.AUTO_SPAN(12), html("A red cell").withStyle(it->it .backgroundColor(UI.Color.RED) ) ) .add(UI.AUTO_SPAN(6), html("a green cell").withStyle(it->it .backgroundColor(Color.GREEN) ) )
The
UIForAnySwing.withFlowLayout()creates the necessaryResponsiveGridFlowLayoutand attaches it to the panel.
Note that a
ResponsiveGridFlowLayoutis required for theFlowCellconfiguration to have any effect. TheFlowCellconfiguration is not compatible with other layout managers likeMigLayout.- Parameters:
numberOfCells- The number of cells to, irrespective of parent size category.- Returns:
- An
FlowCellinstance containing the responsive cell span configuration for a component that is part of a parent component with aResponsiveGridFlowLayoutlayout manager.
-