Center content in scrolled panel

When doing the scroll trick of a panel with defined size containing a vertical layout with undefined size, the vertical layout and any contained components are always top left aligned in the sized panel.

If possible, how can the vertical layout and it’s content be centered in the sized panel?

There is another thread about Window and component alignment, I have code example there. Window is actually special type of Panel, so this layouting should work with Panel as well

Thanks for reply, Tatu,

But I do not think this answers the question I asked, which was not very clear… try again…

In the vaadin 8 docs under panel scrolling it says that panel has to have defined dimensions and a contained vertical layout (for example) has to have undefined dimensions.

When the content of the vertical layout become larger than the panel, scroll bars appear.

The question is–

When the content of the vertical layout is smaller than the panel, is it possible to have this smaller content appear in the center of the panel rather than always being top left?

Hope I have explained it a bit better this time…


After some further investigation using expand ratios produces close to the result I am looking for,