Class Box

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.featurepack.desktop.AbstractContainer
com.vaadin.featurepack.desktop.Box
All Implemented Interfaces:
HasLayout, com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable, com.vaadin.flow.component.FocusNotifier, com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasComponentsOfType<com.vaadin.flow.component.Component>, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, Serializable

@Tag("div") public class Box extends AbstractContainer
The Box class is a container component that uses BoxLayout, and provides methods to create invisible components.
Author:
Vaadin Ltd.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier

    com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.Focusable

    com.vaadin.flow.component.Focusable.FocusJs

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier

    com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>
  • Constructor Summary

    Constructors
    Constructor
    Description
    Box(int axis)
    Creates a new Box with the specified axis.
    Box(BoxLayout layout)
    Creates a new Box with the specified axis.
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.vaadin.flow.component.Component
    Creates an invisible component that expands to fill the space between its neighboring components.
    static Box
    Creates a Box that places components from left to right.
    static com.vaadin.flow.component.Component
    Creates an invisible, fixed-width component.
    static Box
    Creates a Box that places components from top to bottom.
    static com.vaadin.flow.component.Component
    createVerticalStrut(int height)
    Creates an invisible, fixed-height component.
    Gets the layout for the container.
    void
    Sets the layout for this box.

    Methods inherited from class com.vaadin.featurepack.desktop.AbstractContainer

    add, getComponent, getComponentCount, getInsets, remove, removeAll

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, bindVisible, findAncestor, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, getUIOrThrow, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttached

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.BlurNotifier

    addBlurListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.Focusable

    addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndex

    Methods inherited from interface com.vaadin.flow.component.FocusNotifier

    addFocusListener

    Methods inherited from interface com.vaadin.flow.component.HasComponents

    add

    Methods inherited from interface com.vaadin.flow.component.HasComponentsOfType

    add, addComponentAsFirst, addComponentAtIndex, bindChildren, getChildren, getComponentAt, indexOf, remove, replace

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    bindEnabled, isEnabled, setEnabled

    Methods inherited from interface com.vaadin.flow.component.HasSize

    bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
  • Constructor Details

    • Box

      public Box(int axis)
      Creates a new Box with the specified axis.
      Parameters:
      axis - axis to use for placing components
    • Box

      public Box(BoxLayout layout)
      Creates a new Box with the specified axis.
      Parameters:
      axis - axis to use for placing components
  • Method Details

    • getLayout

      public BoxLayout getLayout()
      Description copied from interface: HasLayout
      Gets the layout for the container.
      Specified by:
      getLayout in interface HasLayout
      Overrides:
      getLayout in class AbstractContainer
      Returns:
      the layout instance or null if no layout is set
    • createHorizontalStrut

      public static com.vaadin.flow.component.Component createHorizontalStrut(int width)
      Creates an invisible, fixed-width component. In a horizontal box, this can be used to force a certain amount of space between two components. In a vertical box, this can be used to force the box to be at least the specified width.
      Parameters:
      width - the width of the invisible component, in pixels
      Returns:
      the component
    • createVerticalStrut

      public static com.vaadin.flow.component.Component createVerticalStrut(int height)
      Creates an invisible, fixed-height component. In a vertical box, this can be used to force a certain amount of space between two components. In a horizontal box, this can be used to force the box to be at least the specified height.
      Parameters:
      height - the height of the invisible component, in pixels
      Returns:
      the component
    • createGlue

      public static com.vaadin.flow.component.Component createGlue()
      Creates an invisible component that expands to fill the space between its neighboring components. This only works if the box has width or height specified to be larger than the combined size of child components, so that the glue could take all the remaining space.
      Returns:
      the component
    • setLayout

      public void setLayout(AbstractLayout layout)
      Sets the layout for this box.
      Specified by:
      setLayout in interface HasLayout
      Overrides:
      setLayout in class AbstractContainer
      Parameters:
      layout - the layout to use
      Throws:
      IllegalArgumentException - if the layout is not a BoxLayout
    • createHorizontalBox

      public static Box createHorizontalBox()
      Creates a Box that places components from left to right.
      Returns:
      the box
    • createVerticalBox

      public static Box createVerticalBox()
      Creates a Box that places components from top to bottom.
      Returns:
      the box