Stacked widget

A stacked widget is a container widget that stacks its child widgets on top of each other and displays a single child at any time.

The WStackedWidget accomplishes this using setHidden(bool) on the children. Using currentIndex() and setCurrentIndex(int index) you can retrieve or set the visible widget.

Like its parent WContainerWidget, WStackedWidget is by default not inline. The widget is rendered using an HTML <div> tag and does not provide styling. It can be styled using inline or external CSS as appropriate.

Example
Stacked widget-index 0

Hello

source
  void Stack() {
    WContainerWidget container = new WContainerWidget();
    final WSpinBox sb = new WSpinBox((WContainerWidget) container);
    sb.setRange(0, 2);
    final WStackedWidget stack = new WStackedWidget((WContainerWidget) container);
    new WText("<strong>Stacked widget-index 0</strong><p>Hello</p>", (WContainerWidget) stack);
    new WText("<strong>Stacked widget-index 1</strong><p>This is Wt</p>", (WContainerWidget) stack);
    new WText(
        "<strong>Stacked widget-index 2</strong><p>Do you like it?</p>", (WContainerWidget) stack);
    sb.changed()
        .addListener(
            this,
            () -> {
              if (sb.validate() == ValidationState.Valid) {
                stack.setCurrentIndex(sb.getValue());
              }
            });
  }