Class HorizontalLayout
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.ClickNotifier<HorizontalLayout>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasComponents,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasOrderedComponents,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,FlexComponent,ThemableLayout,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 on by default.HorizontalLayout(com.vaadin.flow.component.Component... children) Convenience constructor to create a layout with the children already inside it.HorizontalLayout(FlexComponent.Alignment alignment, com.vaadin.flow.component.Component... children) Convenience constructor to create a layout with the children and specified vertical alignment.HorizontalLayout(FlexComponent.JustifyContentMode justifyContentMode, com.vaadin.flow.component.Component... children) Convenience constructor to create a layout with the children and specified justifyContentMode. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(com.vaadin.flow.component.Component... components) voidadd(Collection<com.vaadin.flow.component.Component> components) voidaddAndExpand(com.vaadin.flow.component.Component... components) Adds the given components to this layout and sets them as expanded.voidaddComponentAtIndex(int index, com.vaadin.flow.component.Component component) voidaddToEnd(com.vaadin.flow.component.Component... components) Adds the components to the middle slot of this layout.voidaddToEnd(Collection<com.vaadin.flow.component.Component> components) Adds the components to the end slot of this layout.voidaddToMiddle(com.vaadin.flow.component.Component... components) Adds the components to the middle slot of this layout.voidaddToMiddle(Collection<com.vaadin.flow.component.Component> components) Adds the components to the middle slot of this layout.voidaddToStart(com.vaadin.flow.component.Component... components) Adds the components to the start slot of this layout.voidaddToStart(Collection<com.vaadin.flow.component.Component> components) Adds the components to the start slot of this layout.This is the same asgetDefaultVerticalComponentAlignment().getAlignSelf(com.vaadin.flow.component.HasElement component) This is the same asgetVerticalComponentAlignment(Component).Gets the default vertical alignment used by all components without individual alignments inside the layout.getVerticalComponentAlignment(com.vaadin.flow.component.Component component) Gets the individual vertical alignment of a given component.voidreplace(com.vaadin.flow.component.Component oldComponent, com.vaadin.flow.component.Component newComponent) voidsetAlignItems(FlexComponent.Alignment alignment) This is the same assetDefaultVerticalComponentAlignment(Alignment).voidsetAlignSelf(FlexComponent.Alignment alignment, com.vaadin.flow.component.HasElement... components) This is the same assetVerticalComponentAlignment(Alignment, Component...).voidSets the default vertical alignment to be used by all components without individual alignments inside the layout.voidsetSpacing(boolean spacing) Togglesspacingtheme setting for the element.voidsetVerticalComponentAlignment(FlexComponent.Alignment alignment, com.vaadin.flow.component.Component... componentsToAlign) Sets a vertical alignment for individual components inside the layout.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, setFlexGrow, setFlexShrink, setJustifyContentModeMethods inherited from interface com.vaadin.flow.component.HasComponents
add, addComponentAsFirst, 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.orderedlayout.ThemableLayout
getBoxSizing, getSpacing, getThemeList, isMargin, isPadding, isSpacing, isWrap, setBoxSizing, setMargin, setPadding, setSpacing, setSpacing, setWrap
-
Constructor Details
-
HorizontalLayout
public HorizontalLayout()Constructs an empty layout with spacing on by default. -
HorizontalLayout
public HorizontalLayout(com.vaadin.flow.component.Component... children) Convenience constructor to create a layout with the children already inside it.- Parameters:
children- the items to add to this layout- See Also:
-
HorizontalLayout
public HorizontalLayout(FlexComponent.JustifyContentMode justifyContentMode, com.vaadin.flow.component.Component... children) 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:
-
HorizontalLayout
public HorizontalLayout(FlexComponent.Alignment alignment, com.vaadin.flow.component.Component... children) Convenience constructor to create a layout with the children and specified vertical alignment.- Parameters:
alignment- the vertical 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 horizontal layout.
- Specified by:
setSpacingin interfaceThemableLayout- Parameters:
spacing- addsspacingtheme setting iftrueor removes it iffalse
-
setVerticalComponentAlignment
public void setVerticalComponentAlignment(FlexComponent.Alignment alignment, com.vaadin.flow.component.Component... componentsToAlign) Sets a vertical alignment for individual components inside the layout. This individual alignment for the component overrides any alignment set at thesetDefaultVerticalComponentAlignment(Alignment).It effectively sets the
"alignSelf"style value.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- See Also:
-
getVerticalComponentAlignment
public FlexComponent.Alignment getVerticalComponentAlignment(com.vaadin.flow.component.Component component) Gets the individual vertical 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:
-
setDefaultVerticalComponentAlignment
Sets the default vertical alignment to be used by all components without individual alignments inside the layout. Individual components can be aligned by using thesetVerticalComponentAlignment(Alignment, Component...)method.It effectively sets the
"alignItems"style value.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. Settingnullwill reset the alignment to its default- See Also:
-
getDefaultVerticalComponentAlignment
Gets the default vertical alignment used by all components without individual alignments inside the layout.The default alignment is
FlexComponent.Alignment.STRETCH.This is the same as the
getAlignItems()method.- Returns:
- the general alignment used by the layout, never
null
-
setAlignItems
This is the same assetDefaultVerticalComponentAlignment(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 asgetDefaultVerticalComponentAlignment().- Specified by:
getAlignItemsin interfaceFlexComponent- Returns:
- the general alignment used by the layout, never
null
-
setAlignSelf
public void setAlignSelf(FlexComponent.Alignment alignment, com.vaadin.flow.component.HasElement... components) This is the same assetVerticalComponentAlignment(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 asgetVerticalComponentAlignment(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
public void addAndExpand(com.vaadin.flow.component.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 width of this layout is also set to 100%.- Parameters:
components- the components to set, notnull
-
replace
public void replace(com.vaadin.flow.component.Component oldComponent, com.vaadin.flow.component.Component newComponent) - Specified by:
replacein interfaceFlexComponent- Specified by:
replacein interfacecom.vaadin.flow.component.HasOrderedComponents
-
add
This method only adds components to the start slot.
- Specified by:
addin interfacecom.vaadin.flow.component.HasComponents
-
add
public void add(com.vaadin.flow.component.Component... components) This method only adds components to the start slot.
- Specified by:
addin interfacecom.vaadin.flow.component.HasComponents
-
addComponentAtIndex
public void addComponentAtIndex(int index, com.vaadin.flow.component.Component component) - Specified by:
addComponentAtIndexin interfacecom.vaadin.flow.component.HasComponents
-
addToStart
public void addToStart(com.vaadin.flow.component.Component... components) Adds the components to the start slot of this layout.- Parameters:
components- Components to add to the start slot.- Throws:
NullPointerException- if any of the components is null or if the components array is null.
-
addToStart
Adds the components to the start slot of this layout.- Parameters:
components- Components to add to the start slot.- Throws:
NullPointerException- if any of the components is null or if the components array is null.
-
addToMiddle
public void addToMiddle(com.vaadin.flow.component.Component... components) Adds the components to the middle slot of this layout.- Parameters:
components- Components to add to the middle slot.- Throws:
NullPointerException- if any of the components is null or if the components array is null.
-
addToMiddle
Adds the components to the middle slot of this layout.- Parameters:
components- Components to add to the middle slot.- Throws:
NullPointerException- if any of the components is null or if the components array is null.
-
addToEnd
public void addToEnd(com.vaadin.flow.component.Component... components) Adds the components to the middle slot of this layout.- Parameters:
components- Components to add to the middle slot.- Throws:
NullPointerException- if any of the components is null or if the components array is null.
-
addToEnd
Adds the components to the end slot of this layout.- Parameters:
components- Components to add to the middle slot.- Throws:
NullPointerException- if any of the components is null or if the components array is null.
-