Class FlowCell

java.lang.Object
swingtree.layout.FlowCell
All Implemented Interfaces:
AddConstraint

public final class FlowCell extends Object implements AddConstraint
This class is an 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.