Class WGroupBox


public class WGroupBox extends WContainerWidget
A widget which group widgets into a frame with a title.

This is typically used in a form to group certain form elements together.

Usage example:


 enum Vote { Republican , Democrat , NoVote };

 // use a group box as widget container for 3 radio buttons, with a title
 WGroupBox container = new WGroupBox("USA elections vote");

 // use a button group to logically group the 3 options
 WButtonGroup group = new WButtonGroup(this);

 WRadioButton button;
 button = new WRadioButton("I voted Republican", container);
 new WBreak(container);
 group.addButton(button, Vote.Republican.ordinal());

 button = new WRadioButton("I voted Democrat", container);
 new WBreak(container);
 group.addButton(button, Vote.Democrate.ordinal());

 button = new WRadioButton("I didn't vote", container);
 new WBreak(container);
 group.addButton(button, Vote.NoVote.ordinal());

 group.setCheckedButton(group.button(Vote.NoVote.ordinal()));

 

Like WContainerWidget, WGroupBox is by default displayed as a block.

WGroupBox example

CSS

The widget corresponds to the HTML <fieldset> tag, and the title in a nested <legend> tag. This widget does not provide styling, and can be styled using inline or external CSS as appropriate.

  • Constructor Details

  • Method Details

    • getTitle

      public WString getTitle()
      Returns the title.
    • setTitle

      public void setTitle(CharSequence title)
      Sets the title.
    • refresh

      public void refresh()
      Description copied from class: WWidget
      Refresh the widget.

      The refresh method is invoked when the locale is changed using WApplication#setLocale() or when the user hit the refresh button.

      The widget must actualize its contents in response.

      Note: This does not rerender the widget! Calling refresh() usually does not have any effect (unless you've reimplemented refresh() to attach to it an effect).

      Overrides:
      refresh in class WWebWidget
    • addWidget

      public void addWidget(WWidget widget)
      Description copied from class: WContainerWidget
      Adds a child widget to this container.

      The widget is appended to the list of children, and thus also layed-out at the end.

      If, for some reason, you want to be in control of the lifetime of the widget, you can retrieve a unique_ptr with WObject::removeChild()

      Overrides:
      addWidget in class WContainerWidget
    • insertBefore

      public void insertBefore(WWidget widget, WWidget before)
      Description copied from class: WContainerWidget
      Inserts a child widget in this container, before another widget.

      The widget is inserted at the place of the before widget, and subsequent widgets are shifted.

      If, for some reason, you want to be in control of the lifetime of the widget, you can regain ownership of the widget (without any functional implication) using WObject::removeChild()

      Overrides:
      insertBefore in class WContainerWidget
    • insertWidget

      public void insertWidget(int index, WWidget widget)
      Description copied from class: WContainerWidget
      Inserts a child widget in this container at given index.

      The widget is inserted at the given index, and subsequent widgets are shifted.

      If, for some reason, you want to be in control of the lifetime of the widget, you can regain ownership of the widget (without any functional implication) using WObject::removeChild()

      Overrides:
      insertWidget in class WContainerWidget
    • getIndexOf

      public int getIndexOf(WWidget w)
      Description copied from class: WContainerWidget
      Returns the index of a widget.
      Overrides:
      getIndexOf in class WContainerWidget
    • getWidget

      public WWidget getWidget(int index)
      Description copied from class: WContainerWidget
      Returns the widget at index
      Overrides:
      getWidget in class WContainerWidget
    • getCount

      public int getCount()
      Description copied from class: WContainerWidget
      Returns the number of widgets in this container.
      Overrides:
      getCount in class WContainerWidget