Class Text

All Implemented Interfaces:
AttachNotifier, DetachNotifier, HasElement, HasStyle, 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:
  • Constructor Details

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

    • 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:
    • setId

      public void setId(String id)
      The method is not supported for the Text class.

      Always throws an UnsupportedOperationException.

      Overrides:
      setId in class Component
      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 the Text class.

      Always throws an UnsupportedOperationException.

      Overrides:
      setVisible in class Component
      Parameters:
      visible - the component visibility value
      Throws:
      UnsupportedOperationException