Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Layout size to fit contents + stretchable

Herman Bovens
1 decade ago May 08, 2012 1:45pm


I want to implement this simple use case which I'm sure lots of people would want, but it doesn't seem easy to do in Vaadin.

1) create a layout (in my case in a subwindow but that may be irrelevant) that contains some components
2) make sure that all components are visible
3) allow the layout to be stretched (in my case by dragging the subwindow's sizing handle) which causes the components to stretch or be placed further apart

I can use SIZE_UNDEFINED so that the layout will expand to fit all components, but in that case it doesn't stretch.
I can use a fixed or relative size for the layout, and relative sizes for the components so they will stretch, but then it's possible that the size is initially not big enough to contain all the components (or it may be far too big if there are only few components).

What would be the recommended way to do this?