Interface HasSize

All Superinterfaces:
HasElement, Serializable
All Known Subinterfaces:
FlexComponent, InputField<E,V>
All Known Implementing Classes:
AbstractNumberField, Accordion, AccordionPanel, Anchor, Article, Aside, Avatar, AvatarGroup, BigDecimalField, Board, Button, Chart, Checkbox, CheckboxGroup, CollaborationAvatarGroup, CollaborationMessageInput, CollaborationMessageList, ComboBox, ComboBoxBase, ConfirmDialog, Crud, CrudGrid, CustomField, DatePicker, DateTimePicker, DescriptionList, DescriptionList.Description, DescriptionList.Term, Details, Dialog, Div, DrawerToggle, EmailField, Emphasis, FlexLayout, Footer, FormLayout, Grid, GridPro, H1, H2, H3, H4, H5, H6, Header, HorizontalLayout, Hr, HtmlComponent, HtmlContainer, HtmlObject, IFrame, Image, Input, IntegerField, Label, ListBox, ListBoxBase, ListItem, Main, Map, MapBase, MenuBar, MessageInput, MessageList, MultiSelectComboBox, MultiSelectListBox, NativeButton, NativeDetails, NativeDetails.Summary, NativeLabel, Nav, NumberField, OrderedList, Paragraph, Param, PasswordField, Pre, ProgressBar, RadioButtonGroup, RangeInput, RichTextEditor, Row, Scroller, Section, Select, SideNav, Span, SplitLayout, Tabs, TabSheet, TextArea, TextField, TextFieldBase, TimePicker, TreeGrid, UnorderedList, Upload, VerticalLayout, VirtualList

public interface HasSize extends HasElement
Any component implementing this interface supports setting the size of the component using 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 Type
    Method
    Description
    static String
    getCssSize(float size, Unit unit)
    Utility method for internal use.
    default String
    Gets the height defined for the component.
    default Optional<Unit>
    Gets the height unit of the component, if defined.
    default String
    Gets the max-height defined for the component.
    default String
    Gets the max-width defined for the component.
    default String
    Gets the min-height defined for the component.
    default String
    Gets the min-width defined for the component.
    default String
    Gets the width defined for the component.
    default Optional<Unit>
    Gets the width unit of the component, if defined.
    default void
    setHeight(float height, Unit unit)
    Sets the height of the component.
    default void
    setHeight(String height)
    Sets the height of the component.
    default void
    Sets the height of the component to "100%".
    default void
    setMaxHeight(float maxHeight, Unit unit)
    Sets the max-height of the component.
    default void
    setMaxHeight(String maxHeight)
    Sets the max-height of the component.
    default void
    setMaxWidth(float maxWidth, Unit unit)
    Sets the max-width of the component.
    default void
    setMaxWidth(String maxWidth)
    Sets the max-width of the component.
    default void
    setMinHeight(float minHeight, Unit unit)
    Sets the min-height of the component.
    default void
    setMinHeight(String minHeight)
    Sets the min-height of the component.
    default void
    setMinWidth(float minWidth, Unit unit)
    Sets the min-width of the component.
    default void
    setMinWidth(String minWidth)
    Sets the min-width of the component.
    default void
    Sets the width and the height of the component to "100%".
    default void
    Removes the width and the height of the component.
    default void
    setWidth(float width, Unit unit)
    Sets the width of the component.
    default void
    Sets the width of the component.
    default void
    Sets the width of the component to "100%".

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

    getElement
  • Method Details

    • setWidth

      default void setWidth(String width)
      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 width value is null then width is removed.

      Parameters:
      width - the width to set, may be null
    • setWidth

      default void setWidth(float width, Unit unit)
      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

      default void setMinWidth(String minWidth)
      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 minWidth value is null then min-width is removed.

      Parameters:
      minWidth - the min-width value (if null, the property will be removed)
    • setMinWidth

      default void setMinWidth(float minWidth, Unit unit)
      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

      default void setMaxWidth(String maxWidth)
      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 maxWidth value is null then max-width is removed.

      Parameters:
      maxWidth - the max-width value (if null, the property will be removed)
    • setMaxWidth

      default void setMaxWidth(float maxWidth, Unit unit)
      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

      default String 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

      default String 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

      default String 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

      default Optional<Unit> 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

      default void setHeight(String height)
      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 height value is null then height is removed.

      Parameters:
      height - the height to set, may be null
    • setHeight

      default void setHeight(float height, Unit unit)
      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

      default void setMinHeight(String minHeight)
      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 minHeight value is null then min-height is removed.

      Parameters:
      minHeight - the min-height value (if null, the property will be removed)
    • setMinHeight

      default void setMinHeight(float minHeight, Unit unit)
      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

      default void setMaxHeight(String maxHeight)
      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 maxHeight value is null then max-height is removed.

      Parameters:
      maxHeight - the max-height value (if null, the property will be removed)
    • setMaxHeight

      default void setMaxHeight(float maxHeight, Unit unit)
      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

      default String 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

      default String 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

      default String 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

      default Optional<Unit> 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) and setHeight(String) methods with "100%" as the argument value

    • 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

    • 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 value

    • 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) and setHeight(String) methods with null as the argument value

    • getCssSize

      static String getCssSize(float size, Unit unit)
      Utility method for internal use.
      Parameters:
      size - Size
      unit - Unit
      Returns:
      Css format size string