Layout caption not show

Hello everyone,
I’m trying to set to some captions for various layouts - horizontal and vertical. I’ve already checked the demo and every single layout have a caption. I’ve made a simple app to try the caption, but the caption is never show in browser. I’ve also checked with “inspect elements” the generated html/css code and notice that I’m missing “v-has-caption” style. Here is the code, can someone redirect me to somewhere where to read how the caption must be set or to explain why my caption is missing and how to make it work!

@Theme("mytheme")
public class MyUI extends UI {

    @Override
    protected void init(VaadinRequest vaadinRequest) {

        final VerticalLayout layout = new VerticalLayout();

        layout.setCaption("LAYOUT CAPTION TEST");

        final TextField name = new TextField();
        name.setCaption("Type your name here:");
        name.setWidth("234");
        name.setHeight("31");

        Button button = new Button("Click Me");
        
        layout.addComponents(name, button);
        layout.setSizeFull();
        layout.setComponentAlignment(name, Alignment.MIDDLE_RIGHT);
        setContent(layout);
    }

    @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {
    }
}

Hi,

It seems so that the caption of the bottom layout is not visible. I did a brief play with Designer tool and noticed that all other captions, i.e. if I have another layout inside that vertical layout, the caption of it is shown correctly.

Br. Tatu

Hi,

Further investigation revealed, that this is intented design feature. It is the parent layout which renders the caption, and hence the root layout does not have parent layout, the caption cannot be rendered.

Br. Tatu