cell with size of another cell


Is there eny way to set the size of a cell to the size of another (fixed size) cell? The problem is, that I don’t know the size of other cell and I can’t get it as far as I know becuase this information is only available at the client side.
What I want to achieve is, that I have a HorizontalLayout with 3 cells, the left one is empty, but as big as the right one, which is not empty. There are some components which take the size they need. The middle cell should be expanding while the others are fixed, so when I place a label in it and set its alignment to CENTER, it should always in the center of the whole Layout. Or is there any other way to achieve this?

Hi Johannes,

because vaadin’s real component sizes are rendered by your browser it is not possible to set the pixel exact sizes.
But what should work is using com.vaadin.ui.AbstractOrderedLayout#setExpandRatio of your layout (https://vaadin.com/book/-/page/layout.settings.html).


HorizontalLayout layout = new HorizontalLayout();
Component left = getLeft();
Component center = getCenter();
Component right = getRight();


layout.setExpandRatio(left, 1f);
layout.setExpandRatio(right, 1f);

I know it’s not pixel perfect but that way you force same sizes

OK, thank you! To let the left and right instead of the middle cell expand does the trick when I align the content of the right cell to the right border. Sometimes the solution is too simple :slight_smile: