Class CaptionPanel

All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, HasWidgets, HasWidgets.ForIsWidget, IsRenderable, IsWidget, Iterable<Widget>

public class CaptionPanel extends Composite implements HasWidgets.ForIsWidget
A panel that wraps its contents in a border with a caption that appears in the upper left corner of the border. This is an implementation of the fieldset HTML element.
  • Constructor Details

    • CaptionPanel

      public CaptionPanel()
      Constructs a CaptionPanel with an empty caption.
    • CaptionPanel

      public CaptionPanel(SafeHtml caption)
      Constructs a CaptionPanel with specified caption text.
      Parameters:
      caption - the text of the caption
    • CaptionPanel

      public CaptionPanel(String captionText)
      Constructs a CaptionPanel with specified caption text.
      Parameters:
      captionText - the text of the caption, which is automatically escaped
    • CaptionPanel

      public CaptionPanel(String caption, boolean asHTML)
      Constructs a CaptionPanel having the specified caption.
      Parameters:
      caption - the caption to display
      asHTML - if true, the caption param is interpreted as HTML; otherwise, caption is treated as text and automatically escaped
  • Method Details

    • add

      public void add(Widget w)
      Description copied from interface: HasWidgets
      Adds a child widget.
      Specified by:
      add in interface HasWidgets
      Parameters:
      w - the widget to be added
    • add

      public void add(IsWidget w)
      Overloaded version for IsWidget.
      Specified by:
      add in interface HasWidgets.ForIsWidget
      See Also:
    • clear

      public void clear()
      Removes the content widget.
      Specified by:
      clear in interface HasWidgets
    • getCaptionHTML

      public String getCaptionHTML()
      Returns the caption as HTML; note that if the caption was previously set using setCaptionText(String), the return value is undefined.
    • getCaptionText

      public String getCaptionText()
      Returns the caption as text; note that if the caption was previously set using setCaptionHTML(String), the return value is undefined.
    • getContentWidget

      public Widget getContentWidget()
      Accesses the content widget, if present.
      Returns:
      the content widget specified previously in setContentWidget(Widget)
    • iterator

      public Iterator<Widget> iterator()
      Iterates over the singular content widget, if present.
      Specified by:
      iterator in interface HasWidgets
      Specified by:
      iterator in interface Iterable<Widget>
    • remove

      public boolean remove(Widget w)
      Removes the specified widget, although in practice the specified widget must be the content widget.
      Specified by:
      remove in interface HasWidgets
      Parameters:
      w - the widget to remove; note that anything other than the Widget returned by getContentWidget() will have no effect
      Returns:
      true if the widget was present
    • remove

      public boolean remove(IsWidget w)
      Overloaded version for IsWidget.
      Specified by:
      remove in interface HasWidgets.ForIsWidget
      See Also:
    • setCaptionHTML

      public void setCaptionHTML(String html)
      Sets the caption for the panel using an HTML fragment. Pass in empty string to remove the caption completely, leaving just the unadorned panel.
      Parameters:
      html - HTML for the new caption; must not be null
    • setCaptionHTML

      public void setCaptionHTML(SafeHtml html)
      Sets the caption for the panel using a SafeHtml string.
      Parameters:
      html - HTML for the new caption; must not be null
    • setCaptionText

      public void setCaptionText(String text)
      Sets the caption for the panel using text that will be automatically escaped. Pass in empty string to remove the caption completely, leaving just the unadorned panel.
      Parameters:
      text - text for the new caption; must not be null
    • setContentWidget

      public void setContentWidget(Widget w)
      Sets or replaces the content widget within the CaptionPanel.
      Parameters:
      w - the content widget to be set