Package com.vaadin.flow.component
Interface HasText
-
- All Superinterfaces:
HasElement,Serializable
- All Known Implementing Classes:
Anchor,Article,Aside,Button,DescriptionList,DescriptionList.Description,DescriptionList.Term,Div,DrawerToggle,Emphasis,Footer,GeneratedVaadinButton,GridMenuItem,H1,H2,H3,H4,H5,H6,Header,HtmlContainer,HtmlObject,Image,Label,ListItem,Main,MenuItem,MenuItemBase,NativeButton,NativeDetails.Summary,Nav,OrderedList,Paragraph,Pre,RouterLink,Section,Span,Text,UnorderedList
public interface HasText extends HasElement
A component that supports text content.The default implementations set the text as text content of
HasElement.getElement(). Override all methods in this interface if the text should be added to some other element.- Since:
- 1.0
- Author:
- Vaadin Ltd
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classHasText.WhiteSpaceRepresents"white-space"style values.
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default StringgetText()Gets the text content of this component.default HasText.WhiteSpacegetWhiteSpace()Gets the"white-space"style value.default voidsetText(String text)Sets the given string as the content of this component.default voidsetWhiteSpace(HasText.WhiteSpace value)Sets the givenvalueas"white-space"style value.-
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
-
-
-
Method Detail
-
setText
default void setText(String text)
Sets the given string as the content of this component. This removes any existing child components and child elements. To mix text and child components in a component that also supports child components, useHasComponents.add(Component...)with theTextcomponent for the textual parts.- Parameters:
text- the text content to set
-
getText
default String getText()
Gets the text content of this component. This method only considers the text of the actual component. The text contents of any child components or elements are not considered.- Returns:
- the text content of this component, not
null
-
setWhiteSpace
default void setWhiteSpace(HasText.WhiteSpace value)
Sets the givenvalueas"white-space"style value.- Parameters:
value- the"white-space"style value, notnull
-
getWhiteSpace
default HasText.WhiteSpace getWhiteSpace()
Gets the"white-space"style value.The default value is WhiteSpace#NORMAL. If the
"white-space"style value is non standard thennullis returned.- Returns:
- the
"white-space"style value, may benull
-
-