Class Span

All Implemented Interfaces:
Animatable<Span>, CanDrop<Span>, Clickable<Span>, Draggable<Span>, HandleMouseEvents<Span>, Scrollable<Span>, Touchable<Span>

Span component

The component creates an HTML container, that will have components or text be in the same line as the span component. If the content is long, word wrapping will be applied, but the container's initial position will be in the specified line.

Supported events:

AnimationStart AnimationEnd, Click, DoubleClick, MouseDown, MouseDown, MouseLeave, MouseMove, MouseOver, MouseOut, MouseUp, Wheel, Scrollable TouchCancel, TouchEnd, TouchMove, TouchStart, Drop, DragStart, DragEnd

Since:
4.0
Author:
JBStrap
  • Constructor Details

    • Span

      public Span()
      Creates an empty Span component
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Span

      public Span(String text)
      Creates a span component with the specified text inside it
      Parameters:
      text - The text that will appear in the component. If specified as null, nothing will appear in it.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Span

      public Span(String id, String text)
      Creates a span component with the specified text inside it
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      text - The text that will appear in the component. If specified as null, nothing will appear in it.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Span

      public Span(Icon icon, String text)
      Creates a span component with the specified icon and text inside it
      Parameters:
      icon - The icon that will appear in the beginning of the component.For the applicable icons, see the Icon enum. If specified as null, no icon will be used.
      text - The text that will appear in the component. If specified as null, nothing will appear in it.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Span

      public Span(String id, Icon icon, String text)
      Creates a span component with the specified icon and text inside it
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      icon - The icon that will appear in the beginning of the component.For the applicable icons, see the Icon enum. If specified as null, no icon will be used.
      text - The text that will appear in the component. If specified as null, nothing will appear in it.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Span

      public Span(Icon icon, String text, StyleElement... styles)
      Creates a span component with the specified style, icon and text inside it
      Parameters:
      icon - The icon that will appear in the beginning of the component.For the applicable icons, see the Icon enum. If specified as null, no icon will be used.
      text - The text that will appear in the component. If specified as null, nothing will appear in it.
      styles - The style of the text that's in the component. For the applicable styles, see the TextType enum.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Span

      public Span(String id, Icon icon, String text, StyleElement... styles)
      Creates a span component with the specified style, icon and text inside it
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      icon - The icon that will appear in the beginning of the component.For the applicable icons, see the Icon enum. If specified as null, no icon will be used.
      text - The text that will appear in the component. If specified as null, nothing will appear in it.
      styles - The style of the text that's in the component. For the applicable styles, see the TextType enum.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
  • Method Details

    • setText

      public Span setText(String text)
      Sets the text content of the component
      Parameters:
      text - The text that will appear in the component. If specified as null, nothing will appear in it.
      Returns:
      The span component
    • getText

      public String getText()
      Gets the text content of the component
      Returns:
      The text content or null if no text was specified
    • setIcon

      public Span setIcon(Icon icon)
      Sets the icon of the component
      Parameters:
      icon - The icon that will appear in the beginning of the component.For the applicable icons, see the Icon enum. If specified as null, no icon will be used.
      Returns:
      The span component
    • setTextType

      public Span setTextType(TextType textType)
      Sets the text style of the component
      Parameters:
      textType - The style of the text that's in the component. For the applicable styles, see the TextType enum.
      Returns:
      The span component
    • getIcon

      public Icon getIcon()
      Gets the icon of the component
      Returns:
      The icon of the component or null if no icon was specified
    • writeHTML

      public boolean writeHTML(StringWriter writer)
      Description copied from class: Component
      Creates the component's HTML equivalent

      This method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (StringWriter class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return with false. Otherwise, it must return with true.

      Specified by:
      writeHTML in class Component<Span>
      Returns:
      If the componentwas drawn, true, otherwise false