ListSelect has too many rows...


I’m a Vaadin newb and have some issues with the ListSelect component. I have a dataset with two (2) items. With the following piece of code I end up with two rows of content at the top of the list, and two empty (non-selectable) rows at the bottom. To me it seems that the minimum height of the control is always four rows. Is this expected behavior? I use the default (runo) theme.


ListSelect select = new ListSelect("Foobar");


I think the default height is the height which the browser decides for the native list select component. You can of course override this by using setHeight. Use em values so you can specify the height in rows in stead of pixels.

Hi Jouni. You solution seems to be what I’m looking. However, the trick is to use 3em as the unit for two rows, 4em for three rows, etc. Otherwise the last item gets cut in half.

So, adding a:

select.setHeight(select.size() + 1, UNITS_EM);

to the example code after the inserts would solve the issue.

Thanks for the swift help.