Package ej.widget.container
Class Flex
- java.lang.Object
-
- ej.mwt.Widget
-
- ej.mwt.Container
-
- ej.widget.container.Flex
-
public class Flex extends ej.mwt.ContainerLays out child elements in a flexible manner by arranging them along a main axis and a cross axis.The flex layout manager allows you to create flexible and responsive layouts for containers. It arranges child elements individually along the main axis, following the specified direction and justify. Additionally, you can control the alignment of the items along the cross axis. Child elements are positioned based on the order they are added to the layout.
Example of a flex layout with a row horizontal direction, centered along the main axis, and stretched to fill the available height along the cross axis:
Flex flex = new Flex(Direction.ROW, Justify.CENTER, Align.STRETCH);
- See Also:
Flex(Direction, Justify, Align)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFlex.AlignEnum representing the possible values for aligning the row's start position on the cross axis.static classFlex.DirectionEnum representing the possible directions for computing a flex layout.static classFlex.JustifyEnum representing the possible values for justifying the widget's start position on the cross axis.
-
Constructor Summary
Constructors Constructor Description Flex(Flex.Direction direction, Flex.Justify justify, Flex.Align alignment)Creates a flex container specifying its layout parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(ej.mwt.Widget child)protected voidcomputeContentOptimalSize(ej.mwt.util.Size size)booleanisReverse()Checks if the direction is reversed (ROW_REVERSE or COLUMN_REVERSE).booleanisRow()Checks if the main axis is horizontal (ROW or ROW_REVERSE).booleanisStretch()Checks if the current align is STRETCH.protected voidlayOutChildren(int contentWidth, int contentHeight)voidremoveAllChildren()voidremoveChild(ej.mwt.Widget childToRemove)voidsetAlign(Flex.Align align)Sets the align of the flex.voidsetDirection(Flex.Direction direction)Sets the direction of the flex.voidsetJustify(Flex.Justify justify)Sets the justify of the flex.-
Methods inherited from class ej.mwt.Container
changeChildIndex, computeChildOptimalSize, getChild, getChildIndex, getChildren, getChildrenCount, getContentBounds, getContentHeight, getContentWidth, getContentX, getContentY, getWidgetAt, insertChild, layOutAlignedChild, layOutChild, renderChild, renderContent, replaceChild, setHiddenChild, setHiddenChildren, setShownChild, setShownChildren, updateStyle
-
Methods inherited from class ej.mwt.Widget
addClassSelector, contains, containsWidget, getAbsoluteX, getAbsoluteY, getDesktop, getHeight, getParent, getStyle, getWidth, getX, getY, handleEvent, hasClassSelector, isAttached, isEnabled, isInState, isShown, isTransparent, onAttached, onDetached, onHidden, onLaidOut, onShown, removeAllClassSelectors, removeClassSelector, render, requestLayOut, requestRender, requestRender, setClassSelectors, setEnabled, setPosition, setStyle
-
-
-
-
Constructor Detail
-
Flex
public Flex(Flex.Direction direction, Flex.Justify justify, Flex.Align alignment)
Creates a flex container specifying its layout parameters.- Parameters:
direction- the main axis direction for the layout (e.g., Direction.ROW or Flex.Direction.COLUMN).justify- the alignment of items along the main axis (e.g., Justify.START, Justify.CENTER or Justify.END).alignment- the alignment of items along the cross axis (e.g., Align.STRETCH (default), Align.CENTER, Align.END).
-
-
Method Detail
-
computeContentOptimalSize
protected void computeContentOptimalSize(ej.mwt.util.Size size)
- Specified by:
computeContentOptimalSizein classej.mwt.Widget
-
layOutChildren
protected void layOutChildren(int contentWidth, int contentHeight)- Specified by:
layOutChildrenin classej.mwt.Container
-
setDirection
public void setDirection(Flex.Direction direction)
Sets the direction of the flex.- Parameters:
direction- the direction to set.
-
setJustify
public void setJustify(Flex.Justify justify)
Sets the justify of the flex.- Parameters:
justify- the justify to set.
-
setAlign
public void setAlign(Flex.Align align)
Sets the align of the flex.- Parameters:
align- the align to set.
-
isRow
public boolean isRow()
Checks if the main axis is horizontal (ROW or ROW_REVERSE).- Returns:
trueif the main axis is horizontal,falseotherwise.
-
isReverse
public boolean isReverse()
Checks if the direction is reversed (ROW_REVERSE or COLUMN_REVERSE).- Returns:
trueif the direction is reversed,falseotherwise.
-
isStretch
public boolean isStretch()
Checks if the current align is STRETCH.- Returns:
trueif align is STRETCH,falseotherwise.
-
addChild
public void addChild(ej.mwt.Widget child)
- Overrides:
addChildin classej.mwt.Container
-
removeChild
public void removeChild(ej.mwt.Widget childToRemove)
- Overrides:
removeChildin classej.mwt.Container
-
removeAllChildren
public void removeAllChildren()
- Overrides:
removeAllChildrenin classej.mwt.Container
-
-