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 MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static LayoutConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static LayoutConstraint
static LayoutConstraint
static LayoutConstraint
static LayoutConstraint
static LayoutConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static LayoutConstraint
static LayoutConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
static MigAddConstraint
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.miginfocom.layout.AC
AC()
static MigAddConstraint
static FlowCell
AUTO_SPAN
(int numberOfCells) A factory method for creating aFlowCell
instance that will span the given number of cells for each parent size category when used in aResponsiveGridFlowLayout
layout.static FlowCell
AUTO_SPAN
(Configurator<FlowCellConf> configurator) A factory method for creating anAddConstraint
of theFlowCell
type, that is used to define at which parent size category how many cells the component should span as part of aResponsiveGridFlowLayout
layout configuration.static net.miginfocom.layout.CC
CC()
static MigAddConstraint
static MigAddConstraint
GAP_BOTTOM
(int size) static MigAddConstraint
GAP_LEFT
(int size) static LayoutConstraint
GAP_REL
(int size) static MigAddConstraint
GAP_RIGHT
(int size) static MigAddConstraint
GAP_TOP
(int size) static MigAddConstraint
GROW
(int weight) static MigAddConstraint
GROW_X
(int weight) static MigAddConstraint
GROW_Y
(int weight) static MigAddConstraint
HEIGHT
(int min, int pref, int max) static LayoutConstraint
INS
(int insets) static LayoutConstraint
INS
(int top, int left, int bottom, int right) static LayoutConstraint
INSETS
(int insets) static LayoutConstraint
INSETS
(int top, int left, int bottom, int right) static net.miginfocom.layout.LC
LC()
A factory method for creating aLC
instance.static MigAddConstraint
PAD
(int size) static MigAddConstraint
PAD
(int top, int left, int bottom, int right) static MigAddConstraint
PUSH
(int weight) static MigAddConstraint
PUSH_X
(int weight) static MigAddConstraint
PUSH_Y
(int weight) static MigAddConstraint
SHRINK
(int weight) static MigAddConstraint
SHRINK_PRIO
(int priority) static MigAddConstraint
SHRINK_X
(int weight) static MigAddConstraint
SHRINK_Y
(int weight) static MigAddConstraint
SKIP
(int cells) static MigAddConstraint
SPAN
(int times) static MigAddConstraint
SPAN
(int xTimes, int yTimes) static MigAddConstraint
SPAN_X
(int times) static MigAddConstraint
SPAN_Y
(int times) static MigAddConstraint
SPLIT
(int cells) static MigAddConstraint
WIDTH
(int min, int pref, int max) static LayoutConstraint
WRAP
(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 aLC
instance.- Returns:
- A
LC
instance.
-
AC
public static net.miginfocom.layout.AC AC() -
CC
public static net.miginfocom.layout.CC CC() -
AUTO_SPAN
A factory method for creating anAddConstraint
of theFlowCell
type, that is used to define at which parent size category how many cells the component should span as part of aResponsiveGridFlowLayout
layout 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) ) )
it
parameter of theConfigurator
is an instance of theFlowCellConf
class, 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
Configurator
passed to this method is called every time theResponsiveGridFlowLayout
updates 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 necessaryResponsiveGridFlowLayout
and attaches it to the panel.
Note that a
ResponsiveGridFlowLayout
is required for theFlowCell
configuration to have any effect. TheFlowCell
configuration is not compatible with other layout managers likeMigLayout
.- Parameters:
configurator
- AConfigurator
that configures aFlowCellConf
instance.- Returns:
- An
FlowCell
instance containing the responsive cell span configuration for a component that is part of a parent component with aResponsiveGridFlowLayout
layout manager.
-
AUTO_SPAN
A factory method for creating aFlowCell
instance that will span the given number of cells for each parent size category when used in aResponsiveGridFlowLayout
layout.
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 necessaryResponsiveGridFlowLayout
and attaches it to the panel.
Note that a
ResponsiveGridFlowLayout
is required for theFlowCell
configuration to have any effect. TheFlowCell
configuration is not compatible with other layout managers likeMigLayout
.- Parameters:
numberOfCells
- The number of cells to, irrespective of parent size category.- Returns:
- An
FlowCell
instance containing the responsive cell span configuration for a component that is part of a parent component with aResponsiveGridFlowLayout
layout manager.
-