com.vaadin.flow.component.orderedlayout.
Class VerticalLayout
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.orderedlayout.VerticalLayout
-
All Implemented Interfaces:
AttachNotifier
,ClickNotifier<VerticalLayout>
,DetachNotifier
,HasComponents
,HasElement
,HasEnabled
,HasOrderedComponents
,HasSize
,HasStyle
,FlexComponent
,ThemableLayout
,Serializable
@Tag("vaadin-vertical-layout") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="23.1.15") @NpmPackage(value="@vaadin/vertical-layout",version="23.1.15") @NpmPackage(value="@vaadin/vaadin-ordered-layout",version="23.1.15") @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/vertical-layout/src/vaadin-vertical-layout.js") public class VerticalLayout extends Component implements ThemableLayout, FlexComponent, ClickNotifier<VerticalLayout>
Vertical Layout places components top-to-bottom in a column. By default, it has 100% width and undefined height, meaning its width is constrained by its parent component and its height is determined by the components it contains.
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.orderedlayout.FlexComponent
FlexComponent.Alignment, FlexComponent.JustifyContentMode
-
-
Constructor Summary
Constructors Constructor Description VerticalLayout()
Constructs 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.
-
Method Summary
All Methods Modifier and Type Method Description void
addAndExpand(Component... components)
Adds the given components to this layout and sets them as expanded.
FlexComponent.Alignment
getAlignItems()
This is the same as
getDefaultHorizontalComponentAlignment()
.FlexComponent.Alignment
getAlignSelf(HasElement container)
This is the same as
getHorizontalComponentAlignment(Component)
.FlexComponent.Alignment
getDefaultHorizontalComponentAlignment()
Gets the default horizontal alignment used by all components without individual alignments inside the layout.
FlexComponent.Alignment
getHorizontalComponentAlignment(Component component)
Gets the individual horizontal alignment of a given component.
void
setAlignItems(FlexComponent.Alignment alignment)
This is the same as
setDefaultHorizontalComponentAlignment(Alignment)
.void
setAlignSelf(FlexComponent.Alignment alignment, HasElement... elementContainers)
This is the same as
setHorizontalComponentAlignment(Alignment, Component...)
.void
setDefaultHorizontalComponentAlignment(FlexComponent.Alignment alignment)
Sets the default horizontal alignment to be used by all components without individual alignments inside the layout.
void
setHorizontalComponentAlignment(FlexComponent.Alignment alignment, Component... componentsToAlign)
Sets a horizontal alignment for individual components inside the layout.
void
setPadding(boolean padding)
Toggles
padding
theme setting for the element.void
setSpacing(boolean spacing)
Toggles
spacing
theme setting for the element.-
Methods inherited from class com.vaadin.flow.component.Component
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, scrollIntoView, set, setElement, setId, setVisible
-
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.ClickNotifier
addClickListener, addClickShortcut
-
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
-
Methods inherited from interface com.vaadin.flow.component.orderedlayout.FlexComponent
expand, getFlexGrow, getJustifyContentMode, replace, setFlexGrow, setJustifyContentMode
-
Methods inherited from interface com.vaadin.flow.component.HasComponents
add, add, addComponentAsFirst, addComponentAtIndex, remove, removeAll
-
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
-
Methods inherited from interface com.vaadin.flow.component.HasOrderedComponents
getChildren, getComponentAt, getComponentCount, indexOf
-
Methods 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, setWidthFull
-
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Methods inherited from interface com.vaadin.flow.component.orderedlayout.ThemableLayout
getBoxSizing, getThemeList, isMargin, isPadding, isSpacing, setBoxSizing, setMargin
-
-
-
-
Constructor Detail
-
VerticalLayout
public VerticalLayout()
Constructs an empty layout with spacing and padding on by default.
-
VerticalLayout
public VerticalLayout(Component... children)
Convenience constructor to create a layout with the children already inside it.
Parameters:
children
- the items to add to this layoutSee Also:
-
-
Method Detail
-
setSpacing
public void setSpacing(boolean spacing)
Toggles
spacing
theme 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:
setSpacing
in interfaceThemableLayout
Parameters:
spacing
- addsspacing
theme setting iftrue
or removes it iffalse
-
setPadding
public void setPadding(boolean padding)
Toggles
padding
theme 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:
setPadding
in interfaceThemableLayout
Parameters:
padding
- addspadding
theme setting iftrue
or 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 the
setDefaultHorizontalComponentAlignment(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. Settingnull
will reset the alignment to its defaultcomponentsToAlign
- The components to which the individual alignment should be set
-
getHorizontalComponentAlignment
public FlexComponent.Alignment getHorizontalComponentAlignment(Component component)
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)
methodParameters:
component
- The component which individual layout should be readReturns:
the alignment of the component, never
null
See Also:
-
setDefaultHorizontalComponentAlignment
public void setDefaultHorizontalComponentAlignment(FlexComponent.Alignment alignment)
Sets the default horizontal alignment to be used by all components without individual alignments inside the layout. Individual components can be aligned by using the
setHorizontalComponentAlignment(Alignment, Component...)
method.The default alignment is
FlexComponent.Alignment.STRETCH
.It's the same as the
setAlignItems(Alignment)
method.Parameters:
alignment
- the alignment to apply to the components. Settingnull
will reset the alignment to its default
-
getDefaultHorizontalComponentAlignment
public FlexComponent.Alignment getDefaultHorizontalComponentAlignment()
Gets the default horizontal alignment used by all components without individual alignments inside the layout.
The default alignment is
FlexComponent.Alignment.STRETCH
.It's the same as the
getAlignItems()
method.Returns:
the general alignment used by the layout, never
null
-
setAlignItems
public void setAlignItems(FlexComponent.Alignment alignment)
This is the same as
setDefaultHorizontalComponentAlignment(Alignment)
.Specified by:
setAlignItems
in interfaceFlexComponent
Parameters:
alignment
- the alignment to apply to the components. Settingnull
will reset the alignment to its defaultSee Also:
-
getAlignItems
public FlexComponent.Alignment getAlignItems()
This is the same as
getDefaultHorizontalComponentAlignment()
.Specified by:
getAlignItems
in interfaceFlexComponent
Returns:
the general alignment used by the layout, never
null
-
setAlignSelf
public void setAlignSelf(FlexComponent.Alignment alignment, HasElement... elementContainers)
This is the same as
setHorizontalComponentAlignment(Alignment, Component...)
.Specified by:
setAlignSelf
in interfaceFlexComponent
Parameters:
alignment
- the individual alignment for the children components. Settingnull
will reset the alignment to its defaultelementContainers
- The element containers (components) to which the individual alignment should be setSee Also:
-
getAlignSelf
public FlexComponent.Alignment getAlignSelf(HasElement container)
This is the same as
getHorizontalComponentAlignment(Component)
.Specified by:
getAlignSelf
in interfaceFlexComponent
Parameters:
container
- The element container (component) which individual layout should be readReturns:
the alignment of the container, never
null
See Also:
-
addAndExpand
public void addAndExpand(Component... components)
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
-
-