Loading...
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
TUTORIAL

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

Can't edit Spacing between components in VerticalLayout

Alisa Lee
5 years ago May 17, 2016 8:16pm
Alisa Lee
5 years ago May 17, 2016 9:05pm
Manfred Möbus
5 years ago May 17, 2016 11:19pm

Hi,
this effect typically occurs when the height settings are inconsistent. In this case vaadin resorts to giving all components equal heights, i.e. 33 % in your case. The browser console might display a message.

Your "titleLabel" probably does not define a height, so using addComponent is fine here.
What is the height of your "grid"? I assume "100%" since this quite natural in most cases. In this case you should invoke layout.setExpandRatio(grid,1.0f) after the #addComponent(grid) line to explicitly designate the grid to be the control that can get the space available in the layout.
Your "btnsendToAS400" probably also does not define a height, so it should be all right, at the bottom of the layout.

Also if your grid is not height=100%, all three controls turn out to have a fixed height, but your layout has setSizeFull, so vaadin needs to decide what to do with extra space available. If it is your intent to have such space at the end of your content, you should add a further component, e.g. Label dummy = new Label(""), set its height to 100%, and(!) set the expandRatio to 1, then the gap on top also vanishes, and you have your empty part at the bottom.

Hope this helps, otherwise please provide a more complete example with all layout related settings.

Alisa Lee
5 years ago May 18, 2016 1:57pm
Manfred Möbus
5 years ago May 18, 2016 2:49pm
Martin Wildam
5 years ago May 29, 2016 11:34am