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 MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic LayoutConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic LayoutConstraintstatic LayoutConstraintstatic LayoutConstraintstatic LayoutConstraintstatic LayoutConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic LayoutConstraintstatic LayoutConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraintstatic MigAddConstraint -
Method Summary
Modifier and TypeMethodDescriptionstatic net.miginfocom.layout.ACAC()static MigAddConstraintstatic 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()static MigAddConstraintstatic MigAddConstraintGAP_BOTTOM(int size) static MigAddConstraintGAP_LEFT(int size) static LayoutConstraintGAP_REL(int size) static MigAddConstraintGAP_RIGHT(int size) static MigAddConstraintGAP_TOP(int size) static MigAddConstraintGROW(int weight) static MigAddConstraintGROW_X(int weight) static MigAddConstraintGROW_Y(int weight) static MigAddConstraintHEIGHT(int min, int pref, int max) static LayoutConstraintINS(int insets) static LayoutConstraintINS(int top, int left, int bottom, int right) static LayoutConstraintINSETS(int insets) static LayoutConstraintINSETS(int top, int left, int bottom, int right) static net.miginfocom.layout.LCLC()A factory method for creating aLCinstance.static MigAddConstraintPAD(int size) static MigAddConstraintPAD(int top, int left, int bottom, int right) static MigAddConstraintPUSH(int weight) static MigAddConstraintPUSH_X(int weight) static MigAddConstraintPUSH_Y(int weight) static MigAddConstraintSHRINK(int weight) static MigAddConstraintSHRINK_PRIO(int priority) static MigAddConstraintSHRINK_X(int weight) static MigAddConstraintSHRINK_Y(int weight) static MigAddConstraintSKIP(int cells) static MigAddConstraintSPAN(int times) static MigAddConstraintSPAN(int xTimes, int yTimes) static MigAddConstraintSPAN_X(int times) static MigAddConstraintSPAN_Y(int times) static MigAddConstraintSPLIT(int cells) static MigAddConstraintWIDTH(int min, int pref, int max) static LayoutConstraintWRAP(int times)
-
Field Details
-
FILL
-
FILL_X
-
FILL_Y
-
FLOW_X
-
FLOW_Y
-
NO_GRID
-
NO_CACHE
-
DEBUG
-
WRAP
-
SPAN
-
GROW
-
GROW_X
-
GROW_Y
-
SHRINK
-
SHRINK_X
-
SHRINK_Y
-
PUSH
-
PUSH_X
-
PUSH_Y
-
ALIGN_CENTER
-
ALIGN_LEFT
-
ALIGN_RIGHT
-
ALIGN_X_CENTER
-
ALIGN_X_LEFT
-
ALIGN_X_RIGHT
-
ALIGN_Y_CENTER
-
ALIGN_Y_BOTTOM
-
ALIGN_Y_TOP
-
TOP
-
RIGHT
-
BOTTOM
-
LEFT
-
CENTER
-
GAP_LEFT_PUSH
-
GAP_RIGHT_PUSH
-
GAP_TOP_PUSH
-
GAP_BOTTOM_PUSH
-
DOCK_NORTH
-
DOCK_SOUTH
-
DOCK_EAST
-
DOCK_WEST
-
-
Method Details
-
INS
-
INSETS
-
INS
-
INSETS
-
WRAP
-
GAP_REL
-
SPAN
-
SPAN
-
SPAN_X
-
SPAN_Y
-
GROW
-
GROW_X
-
GROW_Y
-
SHRINK
-
SHRINK_X
-
SHRINK_Y
-
SHRINK_PRIO
-
PUSH
-
PUSH_X
-
PUSH_Y
-
SKIP
-
SPLIT
-
WIDTH
-
HEIGHT
-
PAD
-
PAD
-
ALIGN
-
GAP_LEFT
-
GAP_RIGHT
-
GAP_TOP
-
GAP_BOTTOM
-
DOCK
-
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() -
CC
public static net.miginfocom.layout.CC CC() -
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.
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.
-