Scrolling problem with long HTML in a Label

I’m attempting to use a Label to present lengthy HTML text using a Label added as a component into a scrolling Panel. As a test I generate an HTML fragment containing a bunch of lines with
at the end to effectively linefeed.

This works as desired and expected when I modify the autogenerated Panel code from the Visual Designer to eliminate the creation/setContent of the VerticalLayout and instead simply create the label and use panel.addComponent(label).

However, the visual designer insists on adding the default VerticalLayout to Panel. When I do the verticalLayout.addComponent(label), the HTML is displayed but there’s no scrolling in the panel, evidently because it doesn’t detect that it’s needed.

This is getting very annoying - ideas on how to fix? Or a better alternative to rapidly display raw HTML in a pane? It is dynamically generated so it must not be e.g. an embedded browser object referring to an URL, it has to be set via a string.

The Panel is not a layout in itself, but always needs to contain one; by default, it is a VerticalLayout. To get scrolling in a panel, the panel needs to have a defined size (either explicit or relative), and the layout directly inside it (Panel.getContent()) needs to be of undefined size. In your case it seems that this is what you got in the beginning, but it got away from you when you started to change the layouts.

The visual Editor is mostly a prototyping tool, and as such it doesn’t support all cases out of the box; I’d recommend that you use the editor to build your basic layouting, and do the rest by hand.

Nothing wrong with displaying HTML inside a Label, just make sure the label height and containing layout are of undefined size to get the proper sizing.

Ensuring that the layout was of undefined size was the key. Thanks very much, Thomas.

it is amazing how complicated can be this framework… UNDEFINED!!, by the way the Panel is no needed to make the scrollbar appears

Actually it is quite logical. When VerticalLayout in the Panel has undefined height, it is allowed to grow according to its content. Panel has fixed size and scroll bar will appear when VerticalLayouts height is larger than Panel height.