Problem with (re)sizing of a gridlayout inside a panel

I have a problem with the (re)sizing of a gridlayout inside a panel.

(see layout.png)

The panel has got a height of 166px and a width of 100%.
When setting the width of the gridlayout to 100%, the excess text is clipped (see img2.png).

The book of Vaadin says to remove the width of the gridlayout.
This way the panel will render a horizontal scrollbar and all text will be revealed.

This works when the label and value are filled in on init.
But in my case only the label is filled in on init.
The value label is just an empty label of which the caption is changed later in the code.

In my example it renders the following:
(see img3.png)

No values to be found.

Is this a bug? Or is it bad practice to add empty labels to a gridlayout and then changing the caption?
Any suggestions?


Labels have by default 100% width. Make sure to call setSizeUndefined() or setWidth(null) to the Labels in your gridlayout.


Thanks for the response but this doesn’t change a thing.

When debugging with firebug I can see that the right column is rendered but has a width of 0px (with or without ‘setSizeUndefined()’).
The calculation of the width is probably done when the value-label is just an empty label.
When changing the caption, the calculation isn’t re-triggerd.

Looks like a bug…

Ok, then it’s most probably a bug. Value change on the label should definitely trigger size calculation.

Please create a ticket about this bug to the Vaadin trac. Even better if you can provide a (simplified) test case where the bug occurs. Thanks!


Solved the problem!

I did a setCaption on the label, this didn’t trigger the calculation.
When using setValue the problem was solved.

Don’t know if setCaption also needs to trigger the calculation…


good that you got it solved! The setValue method is meant to be used for setting the actual Label content. For example the content modes only apply for the value, not the caption.

On the other hand, I’d say that the caption length change should still trigger the size recalculation. So please create a bug ticket about this issue if you have the time.