Class U<T extends U<T>>

Direct Known Subclasses:
Underline

public class U<T extends U<T>> extends PhrasingContentElement<T>
Represents an HTML <u> element for rendering underlined text.

This class provides functionality to create underlined text elements. While historically used simply for underlining text, the HTML5 specification redefines the <u> element to represent text with an unarticulated, though explicitly rendered, non-textual annotation. This includes proper names in Chinese, misspelled words, or text that should be visually distinguished. For simple styling purposes, CSS text-decoration should be preferred over this semantic element.

Features:

  • Renders text with underline decoration
  • Represents unarticulated but visually distinct text
  • Suitable for proper names in Chinese text
  • Can indicate spelling errors
  • Supports text initialization through constructor
  • Extends
    invalid reference
    TextElement
    for text content management

Usage:


 // Underline a proper name in Chinese
 P paragraph = new P();
 paragraph.addElement(new Text("In Chinese: "));
 paragraph.addElement(new U("李明"));

 // Indicate a misspelled word
 Span spellcheck = new Span();
 spellcheck.addElement(new Text("This is "));
 spellcheck.addElement(new U("incorect"));
 spellcheck.addElement(new Text(" spelling."));

 // Simple underlined text
 U underlined = new U("Important term");

 // Empty element for dynamic content
 U dynamic = new U();
 dynamic.setText("Dynamic content");
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • U

      public U()
      Constructs an empty U element.

      Creates a new <u> element with no initial text content. Text can be added later using methods inherited from

      invalid reference
      TextElement
      .

    • U

      public U(String text)
      Constructs a U element with the specified text content.

      Creates a new <u> element containing the provided text, which will be rendered with underline decoration.

      Parameters:
      text - the text content to display with underline