Class FieldSet

All Implemented Interfaces:
AttachNotifier, DetachNotifier, HasAriaLabel, HasComponents, HasElement, HasEnabled, HasSize, HasStyle, HasText, Serializable

@Tag("fieldset") public class FieldSet extends HtmlContainer implements HasAriaLabel
Represents an HTML <fieldset> element. This component is used to group several UI components within a form, enhancing form accessibility and organization.
See Also:
  • Constructor Details

    • FieldSet

      public FieldSet()
      Creates a new fieldset with an empty legend.
    • FieldSet

      public FieldSet(String legendText)
      Creates a new fieldset with the given legend text.
      Parameters:
      legendText - the legend text to set.
    • FieldSet

      public FieldSet(Component... content)
      Creates a new fieldset with the given content.
      Parameters:
      content - the content component to set.
    • FieldSet

      public FieldSet(String legendText, Component content)
      Creates a new fieldset using the provided legend text and content.
      Parameters:
      legendText - the legend text to set.
      content - the content component to set.
  • Method Details

    • getLegend

      public FieldSet.Legend getLegend()
      Returns the legend component associated with this fieldset.
      Returns:
      the legend component.
    • setLegendText

      public void setLegendText(String text)
      Sets the text of the legend.
      Parameters:
      text - the text to set.
    • getLegendText

      public String getLegendText()
      Gets the text of the legend.
      Returns:
      the text of the legend, or null if no legend is present.
    • getContent

      public Stream<Component> getContent()
      Returns the content of the fieldset.
      Returns:
      Stream of content components
    • setContent

      public void setContent(Component... content)
      Sets the content of the fieldset and removes previously set content. Note: Do not include Legend in the content components. Use other FieldSet methods for setting Legend instead.
      Parameters:
      content - the content components of the fieldset to set.