Package swingtree.layout
Class FlowCell
java.lang.Object
swingtree.layout.FlowCell
- All Implemented Interfaces:
AddConstraint
This class is an
The
AddConstraint
designed as a
component constraint for the ResponsiveGridFlowLayout
layout manager,
allowing you to dynamically adjust the number of grid layout cells
a particular component can span based on the current parent container's size.
Instances of this are wrapper for a Configurator
lambda that
processes a FlowCellConf
instance containing an
array of FlowCellSpanPolicy
instances which
define at which parent size category how many cells the component should span.
This is intended to be created using the
UILayoutConstants.AUTO_SPAN(Configurator)
factory method
as part of a fluent layout configuration oon your UI declarations.
Here is an example of how a usage of this class might look like:
UI.panel().withPrefSize(400, 300)
.withFlowLayout()
.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)
)
)
In the above example, the it
parameter of the Configurator
is an instance of the FlowCellConf
class.
The Configurator
is called every time the ResponsiveGridFlowLayout
updates the layout
of the parent container, so that the number of cells a component spans can be adjusted dynamically.The
UIForAnySwing.withFlowLayout()
creates a ResponsiveGridFlowLayout
and attaches it to the panel.
Note that the FlowCell
configuration may only take effect if the parent
container has a ResponsiveGridFlowLayout
as a LayoutManager
installed.
-
Constructor Summary
ConstructorsConstructorDescriptionFlowCell
(Configurator<FlowCellConf> configurator) The public constructor for the flow-cell layout configuration. -
Method Summary
-
Constructor Details
-
FlowCell
The public constructor for the flow-cell layout configuration. Please useUILayoutConstants.AUTO_SPAN(Configurator)
instead of calling this constructor directly, because this constructor may change between versions!- Parameters:
configurator
- A functional configurator for the cell.
-
-
Method Details
-
toConstraintForLayoutManager
Description copied from interface:AddConstraint
Supplies the actualObject
that is used by a particular layout manager to apply the constraint to a component.- Specified by:
toConstraintForLayoutManager
in interfaceAddConstraint
- Returns:
- The
Object
that is used by a particular layout manager to apply the constraint to a component.
-
toString
-
equals
-
hashCode
public int hashCode()
-