Class VerticalLayout
- All Implemented Interfaces:
AttachNotifier,ClickNotifier<VerticalLayout>,DetachNotifier,HasComponents,HasElement,HasEnabled,HasOrderedComponents,HasSize,HasStyle,HasTheme,FlexComponent,ThemableLayout,HasThemeVariant<VerticalLayoutVariant>,Serializable
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.flow.component.orderedlayout.FlexComponent
FlexComponent.Alignment, FlexComponent.JustifyContentMode -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty layout with spacing and padding on by default.VerticalLayout(Component... children) Convenience constructor to create a layout with the children already inside it.VerticalLayout(FlexComponent.Alignment alignment, Component... children) Convenience constructor to create a layout with the children and specified horizontal alignment.VerticalLayout(FlexComponent.JustifyContentMode justifyContentMode, Component... children) Convenience constructor to create a layout with the children and specified justifyContentMode. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAndExpand(Component... components) Adds the given components to this layout and sets them as expanded.This is the same asgetDefaultHorizontalComponentAlignment().getAlignSelf(HasElement component) This is the same asgetHorizontalComponentAlignment(Component).Gets the default horizontal alignment used by all components without individual alignments inside the layout.getHorizontalComponentAlignment(Component component) Gets the individual horizontal alignment of a given component.voidsetAlignItems(FlexComponent.Alignment alignment) This is the same assetDefaultHorizontalComponentAlignment(Alignment).voidsetAlignSelf(FlexComponent.Alignment alignment, HasElement... components) This is the same assetHorizontalComponentAlignment(Alignment, Component...).voidSets the default horizontal alignment to be used by all components without individual alignments inside the layout.voidsetHorizontalComponentAlignment(FlexComponent.Alignment alignment, Component... componentsToAlign) Sets a horizontal alignment for individual components inside the layout.voidsetPadding(boolean padding) Togglespaddingtheme setting for the element.voidsetSpacing(boolean spacing) Togglesspacingtheme setting for the element.Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.orderedlayout.FlexComponent
expand, getFlexGrow, getFlexShrink, getJustifyContentMode, replace, setFlexGrow, setFlexShrink, setJustifyContentModeMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAllMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasOrderedComponents
getChildren, getComponentAt, getComponentCount, indexOfMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariantsMethods inherited from interface com.vaadin.flow.component.orderedlayout.ThemableLayout
getBoxSizing, getSpacing, getThemeList, isMargin, isPadding, isSpacing, isWrap, setBoxSizing, setMargin, setSpacing, setSpacing, setWrap
-
Constructor Details
-
VerticalLayout
public VerticalLayout()Constructs an empty layout with spacing and padding on by default. -
VerticalLayout
Convenience constructor to create a layout with the children already inside it.- Parameters:
children- the items to add to this layout- See Also:
-
VerticalLayout
Convenience constructor to create a layout with the children and specified justifyContentMode.- Parameters:
justifyContentMode- the justifyContentModechildren- the items to add to this layout- See Also:
-
VerticalLayout
Convenience constructor to create a layout with the children and specified horizontal alignment.- Parameters:
alignment- the horizontal alignmentchildren- the items to add to this layout- See Also:
-
-
Method Details
-
setSpacing
public void setSpacing(boolean spacing) Togglesspacingtheme setting for the element. If a theme supports this attribute, it will apply or remove spacing to the element.This method adds medium spacing to the component theme, to set other options, use
ThemableLayout.getThemeList(). List of options possible:- spacing-xs
- spacing-s
- spacing
- spacing-l
- spacing-xl
Spacing is enabled by default for vertical layout.
- Specified by:
setSpacingin interfaceThemableLayout- Parameters:
spacing- addsspacingtheme setting iftrueor removes it iffalse
-
setPadding
public void setPadding(boolean padding) Togglespaddingtheme setting for the element. If a theme supports this attribute, it will apply or remove padding to the element.Padding is enabled by default for vertical layout.
- Specified by:
setPaddingin interfaceThemableLayout- Parameters:
padding- addspaddingtheme setting iftrueor removes it iffalse
-
setHorizontalComponentAlignment
public void setHorizontalComponentAlignment(FlexComponent.Alignment alignment, Component... componentsToAlign) Sets a horizontal alignment for individual components inside the layout. This individual alignment for the component overrides any alignment set at thesetDefaultHorizontalComponentAlignment(Alignment).The default alignment for individual components is
FlexComponent.Alignment.AUTO.It's the same as the
setAlignSelf(Alignment, HasElement...)method.- Parameters:
alignment- the individual alignment for the children components. Settingnullwill reset the alignment to its defaultcomponentsToAlign- The components to which the individual alignment should be set
-
getHorizontalComponentAlignment
Gets the individual horizontal alignment of a given component.The default alignment for individual components is
FlexComponent.Alignment.AUTO.It's the same as the
getAlignSelf(HasElement)method- Parameters:
component- The component which individual layout should be read- Returns:
- the alignment of the component, never
null - See Also:
-
setDefaultHorizontalComponentAlignment
Sets the default horizontal alignment to be used by all components without individual alignments inside the layout. Individual components can be aligned by using thesetHorizontalComponentAlignment(Alignment, Component...)method.The default alignment is
FlexComponent.Alignment.START.It's the same as the
setAlignItems(Alignment)method.- Parameters:
alignment- the alignment to apply to the components. Settingnullwill reset the alignment to its default
-
getDefaultHorizontalComponentAlignment
Gets the default horizontal alignment used by all components without individual alignments inside the layout.The default alignment is
FlexComponent.Alignment.START.It's the same as the
getAlignItems()method.- Returns:
- the general alignment used by the layout, never
null
-
setAlignItems
This is the same assetDefaultHorizontalComponentAlignment(Alignment).- Specified by:
setAlignItemsin interfaceFlexComponent- Parameters:
alignment- the alignment to apply to the components. Settingnullwill reset the alignment to its default- See Also:
-
getAlignItems
This is the same asgetDefaultHorizontalComponentAlignment().- Specified by:
getAlignItemsin interfaceFlexComponent- Returns:
- the general alignment used by the layout, never
null
-
setAlignSelf
This is the same assetHorizontalComponentAlignment(Alignment, Component...).- Specified by:
setAlignSelfin interfaceFlexComponent- Parameters:
alignment- the individual alignment for the children components. Settingnullwill reset the alignment to its defaultcomponents- The components to which the individual alignment should be set- See Also:
-
getAlignSelf
This is the same asgetHorizontalComponentAlignment(Component).- Specified by:
getAlignSelfin interfaceFlexComponent- Parameters:
component- The component which individual layout should be read- Returns:
- the alignment of the component, never
null - See Also:
-
addAndExpand
Adds the given components to this layout and sets them as expanded. The flex-grow of all added child components are set to 1 so that the expansion will be effective. The height of this layout is also set to 100%.- Parameters:
components- the components to set, notnull
-