At the moment, I’m experimenting a bit with the UI components.
When I set a caption on a label that’s added to a Layoutcomponent, the caption is shown as expected.
But when I wrap that label in a panel first, the caption is never shown.
I’ve tested with several other components and their captions seem to work perfectly.
Is there a reason why labels inside panels cannot have a caption?
Or is this some kind of bug?
This is a “feature”. In Vaadin, excluding a few special cases such as Button, a component’s caption is handled by its parent component. Panel never displays the caption of its content component; you should either set the caption of the Panel, or if you want the caption inside the Panel, wrap your content in a layout (preferably CssLayout as it has the least overhead).
The limitation made more sense in Vaadin 6 where the content of a panel had to be a layout or other component container, and those rarely have captions.
Thats right.
in vaadin 6, I was able to add components directly into the panel using th addComponent method.
in vaadin 7, you used the setContent method to put your label directly into the panel, and the label’s caption is hidden.
Of course, you may create a layout, set the content of your panel to this layout and add your labels into the layout.