layout problem detected is a bug?


If you test the following code by using the below as your main window:

public class CvmAppWindow extends Window{

private static final long serialVersionUID = 1L;

public CvmAppWindow(){
HorizontalLayout titleLayout = new HorizontalLayout();
titleLayout.addComponent(new Label(“test”));



Do an “analyse layout” while in debug mode and you will get a layout problem, which I’m thinking is a bug, but can someone let me know as I’m still learning about how vaadin does layout…

Debug text:

Vaadin DEBUG

  • SearchPage/1b7c984 (width: RELATIVE, 100.0 %)
    • HorizontalLayout/10f305b (width: UNDEFINED)
      • HorizontalLayout/2fdf53 (width: UNDEFINED)
        • Label/178f7a8 (width: RELATIVE, 100.0 %)
          Layout problem detected: Component with relative width inside a HorizontalLayout with no width defined
          Relative sizes were replaced by undefined sizes, components may not render as expected.



PS. I have a small margin around my main window that I can’t seem to get rid of, can someone please let me know how? nm, just found the answer:
((VerticalLayout) mainWindow.getContent()).setMargin(false)


HorizontalLayout has undefined width by default and Label has 100% relative size. This causes a conflict (as-big-as-possible inside as-small-as-possible is a paradox).

Label has a bit uncommon 100% default width. This is because otherwise it doesn’t wrap lines. As also the VerticalLayout, which is the default layout for Windows, has 100% by default, this is not usually a problem. But if you use HorizontalLayout, you have to change the width setting of either component.

The default widths may not always be good for all situations, but they should be for the most typical. In practice, you can’t avoid setting them quite often. The latest
Cheat Sheet
features the default widths for all components.