Vaadin setExpandRatio不起作用

时间:2014-03-27 15:55:29

标签: vaadin vaadin7

此代码有效,中心面板正确扩展:

HorizontalLayout header = new HorizontalLayout(new Label("HEADER"));
HorizontalLayout center = new HorizontalLayout(new Label("CENTER"));
HorizontalLayout footer = new HorizontalLayout(new Label("FOOTER"));        
VerticalLayout verticalLayout = new VerticalLayout(header, center, footer);
verticalLayout.setExpandRatio(center, 1.0f);
verticalLayout.setSizeFull();
setContent(verticalLayout);

但是这段代码不起作用,中心面板展开但左右面板不可见:

VerticalLayout left = new VerticalLayout(new Label("LEFT"));
VerticalLayout center = new VerticalLayout(new Label("CENTER"));
VerticalLayout right = new VerticalLayout(new Label("RIGHT"));
HorizontalLayout horizontalLayout = new HorizontalLayout(left, center, right);
horizontalLayout.setExpandRatio(center, 1.0f);
horizontalLayout.setSizeFull();
setContent(horizontalLayout);

知道为什么以及如何使其发挥作用?

感谢您的帮助!

1 个答案:

答案 0 :(得分:2)

VerticalLayout默认为100%宽度。

设置未定义的宽度:

left.setSizeUndefinded();
right.setSizeUndefined();

left.setWidth(null);
right.setWidth(null);