Class Text
- All Implemented Interfaces:
AttachNotifier,DetachNotifier,HasElement,HasStyle,HasText,Serializable
Text node doesn't support setting any attribute or property so you may not
use Element API (and Text doesn'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 a Text component is set a text.
If you need a text component which can be styled then check Span
class (from flow-html-components) module.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
HasText.WhiteSpace -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddClassName(String className) The method is not supported for theTextclass.voidaddClassNames(String... classNames) The method is not supported for theTextclass.getText()Gets the text of the component.booleanremoveClassName(String className) The method is not supported for theTextclass.voidremoveClassNames(String... classNames) The method is not supported for theTextclass.protected <T> voidset(PropertyDescriptor<T, ?> descriptor, T value) Sets the value of the given component property.voidsetClassName(String className) The method is not supported for theTextclass.voidsetClassName(String className, boolean set) The method is not supported for theTextclass.voidThe method is not supported for theTextclass.voidSets 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, 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, setElementMethods 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.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasStyle
getClassName, getClassNames, getStyle, hasClassNameMethods inherited from interface com.vaadin.flow.component.HasText
getWhiteSpace, setWhiteSpace
-
Constructor Details
-
Text
Creates an instance using the given text.- Parameters:
text- the text to show,nullis interpreted as an empty string
-
-
Method Details
-
setText
Sets the text of the component. -
getText
Gets the text of the component. -
set
Description copied from class:ComponentSets the value of the given component property. -
setId
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- always, as text nodes cannot have IDs
-
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- always, as text nodes cannot have visibility changed
-
addClassName
The method is not supported for theTextclass.Always throws an
UnsupportedOperationException.- Specified by:
addClassNamein interfaceHasStyle- Parameters:
className- the CSS class name to add, notnull- Throws:
UnsupportedOperationException- always, as text nodes cannot have class names
-
removeClassName
The method is not supported for theTextclass.Always throws an
UnsupportedOperationException.- Specified by:
removeClassNamein interfaceHasStyle- Parameters:
className- the CSS class name to remove, notnull- Returns:
trueif the class name was removed,falseif the class list didn't contain the class name- Throws:
UnsupportedOperationException- always, as text nodes cannot have class names
-
setClassName
The method is not supported for theTextclass.Always throws an
UnsupportedOperationException.- Specified by:
setClassNamein interfaceHasStyle- Parameters:
className- a space-separated string of class names to set, ornullto remove all class names- Throws:
UnsupportedOperationException- always, as text nodes cannot have class names
-
setClassName
The method is not supported for theTextclass.Always throws an
UnsupportedOperationException.- Specified by:
setClassNamein interfaceHasStyle- Parameters:
className- the class name to set or remove, notnullset-trueto set the class name,falseto remove it- Throws:
UnsupportedOperationException- always, as text nodes cannot have class names
-
addClassNames
The method is not supported for theTextclass.Always throws an
UnsupportedOperationException.- Specified by:
addClassNamesin interfaceHasStyle- Parameters:
classNames- the CSS class name or class names to be added to the component- Throws:
UnsupportedOperationException- always, as text nodes cannot have class names
-
removeClassNames
The method is not supported for theTextclass.Always throws an
UnsupportedOperationException.- Specified by:
removeClassNamesin interfaceHasStyle- Parameters:
classNames- the CSS class name or class names to be removed from the component- Throws:
UnsupportedOperationException- always, as text nodes cannot have class names
-