Interface HasSize
- All Superinterfaces:
HasElement,Serializable
- All Known Subinterfaces:
FlexComponent,InputField<E,V>
- All Known Implementing Classes:
Abbr,AbstractNumberField,Accordion,AccordionPanel,Anchor,Article,Aside,Avatar,AvatarGroup,Badge,BigDecimalField,Board,Button,Card,Chart,Checkbox,CheckboxGroup,Code,CollaborationAvatarGroup,CollaborationMessageInput,CollaborationMessageList,ComboBox,ComboBoxBase,ConfirmDialog,Crud,CrudGrid,CustomField,Dashboard,DatePicker,DateTimePicker,DescriptionList,DescriptionList.Description,DescriptionList.Term,Details,Dialog,Div,DrawerToggle,EmailField,Emphasis,FieldSet,FieldSet.Legend,FlexLayout,Footer,FormLayout,Grid,GridPro,H1,H2,H3,H4,H5,H6,Header,HorizontalLayout,Hr,HtmlComponent,HtmlContainer,HtmlObject,IFrame,Image,Input,IntegerField,ListBox,ListBoxBase,ListItem,Main,Map,MapBase,Markdown,MasterDetailLayout,MenuBar,MessageInput,MessageList,MultiSelectComboBox,MultiSelectListBox,NativeButton,NativeDetails,NativeDetails.Summary,NativeLabel,NativeTable,NativeTableBody,NativeTableCaption,NativeTableCell,NativeTableFooter,NativeTableHeader,NativeTableHeaderCell,NativeTableRow,Nav,NumberField,OrderedList,Paragraph,Param,PasswordField,Pre,ProgressBar,RadioButtonGroup,RangeInput,RangeSlider,RichTextEditor,Row,Scroller,Section,Select,SideNav,Slider,Span,SplitLayout,Tabs,TabSheet,TextArea,TextField,TextFieldBase,TimePicker,TreeGrid,UnorderedList,Upload,UploadButton,UploadDropZone,UploadFileList,VerticalLayout,VirtualList
setWidth(String), setHeight(String),
setMaxWidth(String), setMaxHeight(String),
setMinWidth(String), and setMinHeight(String). The sizes
are set on the element as inline styles, i.e. using
Element.getStyle().- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidbindHeight(Signal<String> heightSignal) Binds aSignal's value to the height of this component and keeps the height synchronized with the signal value while the component is in attached state.default voidBinds aSignal's value to the width of this component and keeps the width synchronized with the signal value while the component is in attached state.static StringgetCssSize(float size, Unit unit) Utility method for internal use.default StringGets the height defined for the component.Gets the height unit of the component, if defined.default StringGets the max-height defined for the component.default StringGets the max-width defined for the component.default StringGets the min-height defined for the component.default StringGets the min-width defined for the component.default StringgetWidth()Gets the width defined for the component.Gets the width unit of the component, if defined.default voidSets the height of the component.default voidSets the height of the component.default voidSets the height of the component to "100%".default voidsetMaxHeight(float maxHeight, Unit unit) Sets the max-height of the component.default voidsetMaxHeight(String maxHeight) Sets the max-height of the component.default voidsetMaxWidth(float maxWidth, Unit unit) Sets the max-width of the component.default voidsetMaxWidth(String maxWidth) Sets the max-width of the component.default voidsetMinHeight(float minHeight, Unit unit) Sets the min-height of the component.default voidsetMinHeight(String minHeight) Sets the min-height of the component.default voidsetMinWidth(float minWidth, Unit unit) Sets the min-width of the component.default voidsetMinWidth(String minWidth) Sets the min-width of the component.default voidSets the width and the height of the component to "100%".default voidRemoves the width and the height of the component.default voidSets the width of the component.default voidSets the width of the component.default voidSets the width of the component to "100%".Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
Method Details
-
setWidth
Sets the width of the component.The width should be in a format understood by the browser, e.g. "100px" or "2.5em".
If the provided
widthvalue is null then width is removed.- Parameters:
width- the width to set, may benull
-
setWidth
Sets the width of the component. Negative number implies unspecified size (terminal is free to set the size).- Parameters:
width- the width of the object.unit- the unit used for the width.
-
setMinWidth
Sets the min-width of the component.The width should be in a format understood by the browser, e.g. "100px" or "2.5em".
If the provided
minWidthvalue is null then min-width is removed.- Parameters:
minWidth- the min-width value (ifnull, the property will be removed)
-
setMinWidth
Sets the min-width of the component. Negative number implies unspecified size (terminal is free to set the size).- Parameters:
minWidth- the min-width of the object.unit- the unit used for the min-width.
-
setMaxWidth
Sets the max-width of the component.The width should be in a format understood by the browser, e.g. "100px" or "2.5em".
If the provided
maxWidthvalue is null then max-width is removed.- Parameters:
maxWidth- the max-width value (ifnull, the property will be removed)
-
setMaxWidth
Sets the max-width of the component. Negative number implies unspecified size (terminal is free to set the size).- Parameters:
maxWidth- the max-width of the object.unit- the unit used for the max-width.
-
getWidth
Gets the width defined for the component.Note that this does not return the actual size of the component but the width which has been set using
setWidth(String).- Returns:
- the width which has been set for the component
-
getMinWidth
Gets the min-width defined for the component.Note that this does not return the actual size of the component but the min-width which has been set using
setMinWidth(String).- Returns:
- the min-width which has been set for the component
-
getMaxWidth
Gets the max-width defined for the component.Note that this does not return the actual size of the component but the max-width which has been set using
setMaxWidth(String).- Returns:
- the max-width which has been set for the component
-
getWidthUnit
Gets the width unit of the component, if defined.- Returns:
- an optional width unit for the component, or an empty optional if no width unit has been set
-
setHeight
Sets the height of the component.The height should be in a format understood by the browser, e.g. "100px" or "2.5em".
If the provided
heightvalue is null then height is removed.- Parameters:
height- the height to set, may benull
-
setHeight
Sets the height of the component. Negative number implies unspecified size (terminal is free to set the size).- Parameters:
height- the height of the object.unit- the unit used for the height.
-
setMinHeight
Sets the min-height of the component.The height should be in a format understood by the browser, e.g. "100px" or "2.5em".
If the provided
minHeightvalue is null then min-height is removed.- Parameters:
minHeight- the min-height value (ifnull, the property will be removed)
-
setMinHeight
Sets the min-height of the component. Negative number implies unspecified size (terminal is free to set the size).- Parameters:
minHeight- the min-height of the object.unit- the unit used for the min-height.
-
setMaxHeight
Sets the max-height of the component.The height should be in a format understood by the browser, e.g. "100px" or "2.5em".
If the provided
maxHeightvalue is null then max-height is removed.- Parameters:
maxHeight- the max-height value (ifnull, the property will be removed)
-
setMaxHeight
Sets the max-height of the component. Negative number implies unspecified size (terminal is free to set the size).- Parameters:
maxHeight- the max-height of the object.unit- the unit used for the max-height.
-
getHeight
Gets the height defined for the component.Note that this does not return the actual size of the component but the height which has been set using
setHeight(String).- Returns:
- the height which has been set for the component
-
getMinHeight
Gets the min-height defined for the component.Note that this does not return the actual size of the component but the min-height which has been set using
setMinHeight(String).- Returns:
- the min-height which has been set for the component
-
getMaxHeight
Gets the max-height defined for the component.Note that this does not return the actual size of the component but the max-height which has been set using
setMaxHeight(String).- Returns:
- the max-height which has been set for the component
-
getHeightUnit
Gets the height unit of the component, if defined.- Returns:
- an optional height unit for the component, or an empty optional if no height unit has been set
-
setSizeFull
default void setSizeFull()Sets the width and the height of the component to "100%".This is just a convenience method which delegates its call to the
setWidth(String)andsetHeight(String)methods with "100%" as the argument valueWhen adding full-size components as a child of a Vaadin layout component that is based on CSS Flexbox, such as HorizontalLayout or VerticalLayout, this can result in unexpected behavior. For example, other components with a fixed size may shrink to allow the full-size component to take up as much space as possible, or the full-size component may cause the layout to overflow. To improve this, you can enable the
com.vaadin.experimental.layoutComponentImprovementsfeature flag to effectively make full-size components take up the remaining space in the layout, rather than explicitly using 100% size of the layout. This applies additional CSS styles that allow the component to shrink below 100% if there are other components with fixed or relative sizes in the layout. -
setWidthFull
default void setWidthFull()Sets the width of the component to "100%".This is just a convenience method which delegates its call to the
setWidth(String)with "100%" as the argument value.When adding full-size components as a child of a Vaadin layout component that is based on CSS Flexbox, such as HorizontalLayout or VerticalLayout, this can result in unexpected behavior. For example, other components with a fixed size may shrink to allow the full-size component to take up as much space as possible, or the full-size component may cause the layout to overflow. To improve this, you can enable the
com.vaadin.experimental.layoutComponentImprovementsfeature flag to effectively make full-size components take up the remaining space in the layout, rather than explicitly using 100% size of the layout. This applies additional CSS styles that allow the component to shrink below 100% if there are other components with fixed or relative sizes in the layout. -
setHeightFull
default void setHeightFull()Sets the height of the component to "100%".This is just a convenience method which delegates its call to the
setHeight(String)with "100%" as the argument valueWhen adding full-size components as a child of a Vaadin layout component that is based on CSS Flexbox, such as HorizontalLayout or VerticalLayout, this can result in unexpected behavior. For example, other components with a fixed size may shrink to allow the full-size component to take up as much space as possible, or the full-size component may cause the layout to overflow. To improve this, you can enable the
com.vaadin.experimental.layoutComponentImprovementsfeature flag to effectively make full-size components take up the remaining space in the layout, rather than explicitly using 100% size of the layout. This applies additional CSS styles that allow the component to shrink below 100% if there are other components with fixed or relative sizes in the layout. -
setSizeUndefined
default void setSizeUndefined()Removes the width and the height of the component.This is just a convenience method which delegates its call to the
setWidth(String)andsetHeight(String)methods with null as the argument value -
bindWidth
Binds aSignal's value to the width of this component and keeps the width synchronized with the signal value while the component is in attached state. When the component is in detached state, signal value changes have no effect.nullsignal unbinds the existing binding.The width should be in a format understood by the browser, e.g. "100px" or "2.5em".
While a Signal is bound to the width, any attempt to set the width manually throws
BindingActiveException. Same happens when trying to bind a new Signal while one is already bound.Example of usage:
ValueSignal<String> signal = new ValueSignal<>("200px"); Div component = new Div(); add(component); component.bindWidth(signal); signal.set("300px"); // The component width is set to "300px"- Parameters:
widthSignal- the signal to bind, notnull- Throws:
BindingActiveException- thrown when there is already an existing binding- See Also:
-
bindHeight
Binds aSignal's value to the height of this component and keeps the height synchronized with the signal value while the component is in attached state. When the component is in detached state, signal value changes have no effect.The height should be in a format understood by the browser, e.g. "100px" or "2.5em".
While a Signal is bound to the height, any attempt to set the height manually throws
BindingActiveException. Same happens when trying to bind a new Signal while one is already bound.Example of usage:
ValueSignal<String> signal = new ValueSignal<>("200px"); Div component = new Div(); add(component); component.bindHeight(signal); signal.set("300px"); // The component height is set to "300px"- Parameters:
heightSignal- the signal to bind, notnull- Throws:
BindingActiveException- thrown when there is already an existing binding- See Also:
-
getCssSize
Utility method for internal use.- Parameters:
size- Sizeunit- Unit- Returns:
- Css format size string
-