Package com.vaadin.flow.component
Class Text
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.Text
-
- All Implemented Interfaces:
AttachNotifier,DetachNotifier,HasElement,HasText,Serializable
public class Text extends Component implements HasText
A component which encapsulates the given text in a text node.Text node doesn't support setting any attribute or property so you may not use Element API (and
Textdoesn't provide any such contract) for setting attribute/property. It implies that you may not style this component as well. Any attempt to set attribute/property value throws an exception. The only available API for aTextcomponent is set a text.If you need a text component which can be styled then check
Spanclass (fromflow-html-components) module.- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
HasText.WhiteSpace
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetText()Gets the text of the component.protected <T> voidset(PropertyDescriptor<T,?> descriptor, T value)Sets the value of the given component property.voidsetId(String id)The method is not supported for theTextclass.voidsetText(String text)Sets the text of the component.voidsetVisible(boolean visible)The method is not supported for theTextclass.-
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, setElement
-
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.DetachNotifier
addDetachListener
-
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
Methods inherited from interface com.vaadin.flow.component.HasText
getWhiteSpace, setWhiteSpace
-
-
-
-
Constructor Detail
-
Text
public Text(String text)
Creates an instance using the given text.- Parameters:
text- the text to show,nullis interpreted as an empty string
-
-
Method Detail
-
setText
public void setText(String text)
Sets the text of the component.
-
getText
public String getText()
Gets the text of the component.
-
set
protected <T> void set(PropertyDescriptor<T,?> descriptor, T value)
Description copied from class:ComponentSets the value of the given component property.- Overrides:
setin classComponent- Type Parameters:
T- type of the value to set- Parameters:
descriptor- the descriptor for the property to set, notnullvalue- the new property value to set- See Also:
PropertyDescriptor
-
setId
public void setId(String id)
The method is not supported for theTextclass.Always throws an
UnsupportedOperationException.- Overrides:
setIdin classComponent- Parameters:
id- the id to set, or""to remove any previously set id- Throws:
UnsupportedOperationException
-
setVisible
public void setVisible(boolean visible)
The method is not supported for theTextclass.Always throws an
UnsupportedOperationException.- Overrides:
setVisiblein classComponent- Parameters:
visible- the component visibility value- Throws:
UnsupportedOperationException
-
-