Class 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 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:
    Serialized Form
    • Constructor Detail

      • Text

        public Text​(String text)
        Creates an instance using the given text.
        Parameters:
        text - the text to show, null is interpreted as an empty string
    • Method Detail

      • setText

        public void setText​(String text)
        Sets the text of the component.
        Specified by:
        setText in interface HasText
        Parameters:
        text - the text of the component, null is interpreted as an empty string
      • getText

        public String getText()
        Gets the text of the component.
        Specified by:
        getText in interface HasText
        Returns:
        the text of the component, not null
      • set

        protected <T> void set​(PropertyDescriptor<T,​?> descriptor,
                               T value)
        Description copied from class: Component
        Sets the value of the given component property.
        Overrides:
        set in class Component
        Type Parameters:
        T - type of the value to set
        Parameters:
        descriptor - the descriptor for the property to set, not null
        value - the new property value to set
        See Also:
        PropertyDescriptor