SpacerLabel guzzles normal labels - ?!

Vaadin 6.5.2, last Chrome/FF
Simple Window with one component:

HorizontalLayout hl = new HorizontalLayout();
hl.setWidth("100%");//toolbar
hl.addComponent(new Label("first"));
hl.addComponent(new Label("second"));

final Label spacer = new Label();
spacer.setWidth("100%");
hl.addComponent(spacer);
hl.setExpandRatio(spacer, 1);

addComponent(hl);

run-> WIndow is empty

?debug shows:

Layouts analyzed on server, total top level problems: 0

Client side notifications

The following relative sized components were rendered to a zero size container on the client side. Note that these are not necessarily invalid states, but reported here as they might be.
Horizontally zero size:

VLabel inside VHorizontalLayout
Emphasize components parent in UI (the actual component is not visible)
VLabel inside VHorizontalLayout
Emphasize components parent in UI (the actual component is not visible)


Processing time was 22ms for 1591 characters of JSON
Referenced paintables: 8

Why?

Looks like bug…

Some investigation:

HorizontalLayout hl = new HorizontalLayout();
hl.setWidth("100%");

final Label first = new Label("first");
hl.addComponent(first);
first.setWidth("20%");//helpless

final Label second = new Label("second");
second.setWidth("100px");//visible now!
hl.addComponent(second);

final Label spacer = new Label();
spacer.setWidth("100%");
hl.addComponent(spacer);
hl.setExpandRatio(spacer, 1);
addComponent(hl);

Not a bug, but the default width of a Label is 100%. Therefore, if some other component wants to take the space, the first labels are left with none.

To fix this, set the width of the first two labels as undefined (or a fixed size if you know a good size). I would recommend creating a subclass of Label that does this if you need this more than two or three times.

As a side note, the 20% here refers to the size of the “slot” for the component in HorizontalLayout, and IIRC does not affect the size of the slot itself - this might not be obvious.

Thank You!
I was thinking that “100%” means “>= minimal component size”, but not < actual content.