Class BoxLayout
- All Implemented Interfaces:
Serializable, CssEmittingLayoutManager, LayoutManager, LayoutManager2
BoxLayout. Joins
FlowLayout / BorderLayout as the
third built-in layout manager. Under D_layout_css_on_content,
LayoutManager.layoutContainer(Container) writes
display: flex; flex-direction: row|column to the container's
peer content element via
EHelper.applyContainerCss(Element, String, Map).
Hand-written rather than generator-emitted: the generator's
root-class detection assumes Component-hierarchy ancestry and would
emit a peer field, which a LayoutManager doesn't have. Lives
in vaadinx.swing (not vaadinx.awt) because the JDK
class is javax.swing.BoxLayout, not java.awt.BoxLayout.
RTL caveat. JDK BoxLayout flips LINE_AXIS between row
and row-reverse based on the container's
ComponentOrientation; PAGE_AXIS flips for
vertical-text orientations. CSS flex-direction isn't
orientation-aware, and tracking orientation at layoutContainer
time would require rebuilding the dispatch path. We pin the LTR
mapping (X_AXIS/LINE_AXIS → row,
Y_AXIS/PAGE_AXIS → column) per R_layouts_close_enough — same shape
as BorderLayout's LINE_START/LINE_END caveat.
Per-child sizing. JDK BoxLayout reads each child's
getMinimumSize / getPreferredSize / getMaximumSize
and getAlignmentX / getAlignmentY to distribute space.
Vaadin's flex defaults (flex: 0 0 auto) give children their
intrinsic content size with no growth — close-enough for the canonical
Swing pattern (vertical row stack with Box.createVerticalStrut(int)
/ Box.createVerticalGlue() carrying spacing and expansion).
Setting Component.alignmentX/Y doesn't write a per-child
align-self today: JComponent.setAlignmentX/Y is
onNoop and the getters always return 0.5f, so any write
would be align-self: center — flex's default, so adds DOM noise
with zero information. R_layouts_close_enough; revisit when alignment becomes a stored
property.
Bound to one container. Like JDK BoxLayout, instances are
tied to the Container passed at construction time:
invalidateLayout(Container) (and
LayoutManager.layoutContainer(Container)) throw AWTError when called
with a different container, matching Swing per R_match_swing_errors.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLayoutComponent(String name, Component comp) voidaddLayoutComponent(Component comp, Object constraints) Per-child CSS for onechildofparent;null(the default) means the child needs none.containerCss(Container parent) Container-wide CSS forparent's peer content element (its<div>).final intgetAxis()floatgetLayoutAlignmentX(Container target) floatgetLayoutAlignmentY(Container target) final ContainervoidinvalidateLayout(Container target) maximumLayoutSize(Container target) minimumLayoutSize(Container parent) preferredLayoutSize(Container parent) voidtoString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface CssEmittingLayoutManager
cssLayoutName, layoutContainer
-
Field Details
-
X_AXIS
public static final int X_AXIS- See Also:
-
Y_AXIS
public static final int Y_AXIS- See Also:
-
LINE_AXIS
public static final int LINE_AXIS- See Also:
-
PAGE_AXIS
public static final int PAGE_AXIS- See Also:
-
-
Constructor Details
-
BoxLayout
-
-
Method Details
-
getAxis
public final int getAxis() -
getTarget
-
addLayoutComponent
- Specified by:
addLayoutComponentin interfaceLayoutManager
-
addLayoutComponent
- Specified by:
addLayoutComponentin interfaceLayoutManager2
-
removeLayoutComponent
- Specified by:
removeLayoutComponentin interfaceLayoutManager
-
preferredLayoutSize
- Specified by:
preferredLayoutSizein interfaceLayoutManager
-
minimumLayoutSize
- Specified by:
minimumLayoutSizein interfaceLayoutManager
-
maximumLayoutSize
- Specified by:
maximumLayoutSizein interfaceLayoutManager2
-
getLayoutAlignmentX
- Specified by:
getLayoutAlignmentXin interfaceLayoutManager2
-
getLayoutAlignmentY
- Specified by:
getLayoutAlignmentYin interfaceLayoutManager2
-
invalidateLayout
- Specified by:
invalidateLayoutin interfaceLayoutManager2
-
containerCss
Description copied from interface:CssEmittingLayoutManagerContainer-wide CSS forparent's peer content element (its<div>).- Specified by:
containerCssin interfaceCssEmittingLayoutManager- Returns:
- property→value map; a
nullvalue removes the property, an absent key is left untouched.
-
childCss
Description copied from interface:CssEmittingLayoutManagerPer-child CSS for onechildofparent;null(the default) means the child needs none. Called once per child per pass, afterCssEmittingLayoutManager.containerCss(Container)(see the call-order contract).- Specified by:
childCssin interfaceCssEmittingLayoutManager
-
toString
-