Captions for components don't align with components.

I’m trying to use textfield and combobox, and i want to align the components BOTTOM_CENTER or MIDDLE_CENTER, but the captions don’t move with the components in gridlayout.

Example:

gridLayout.setComponentAlignment(cboExample,Alignment.
TOP_CENTER
);

gridLayout.setComponentAlignment(cboExample,Alignment.
BOTTOM_CENTER
);


I get this huge gap,

Is there a workaround for this?

I guess you have found this bug. This is indeed an issue with GridLayout. If it is possible for you to create the design using combination HorizontalLayout and VerticalLayout, it is a possible workaround. The issue does not happen with them.

https://github.com/vaadin/framework/issues/7895

Oh thank you, that worked very well!

           VerticalLayout vL = new VerticalLayout();
            vL.addComponent(txtBox);
            vL.setComponentAlignment(txtBox,Alignment.BOTTOM_CENTER);
            gridLayout.setComponentAlignment(vL,Alignment.BOTTOM_CENTER);