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.

Add blank row on VerticalLayout

Yohan Yudanara
1 decade ago Apr 26, 2010 8:25am
Marko Grönroos
1 decade ago Apr 26, 2010 9:44am

If you want to have some empty space in VerticalLayout, adding an invisible component, such as a Label, is one way. Notice that if the label text is empty, it will not take any space. If you give ordinary space as the label text, as with "[tt]new Label(" ")[/tt]", it will also not be displayed. You need to give a non-breaking space character, such as [tt] [/tt] or [tt] [/tt].

layout.addComponent(new Label(" ", Label.CONTENT_XHTML));

However, you can use an empty label IF you provide a height for it:

Label emptyLabel2 = new Label("");
emptyLabel2.setHeight("1em");
layout.addComponent(emptyLabel2);

This allows adjusting the height of the gap, unlike the non-breaking space.

Alternatively, you could add some margin to the component above or below the space. Using a Label may be a bit easier though.

Last updated on Apr, 26th 2010
Yohan Yudanara
1 decade ago Apr 26, 2010 10:09am
Dmitri Livotov
1 decade ago Apr 26, 2010 11:17am
Marko Grönroos
1 decade ago Apr 26, 2010 11:28am