2014-03-27 45 views
1

此代碼的工作,中央面板正確擴展:Vaadin setExpandRatio不起作用

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); 

任何想法爲什麼以及如何使它工作?

感謝您的幫助!

回答

2

A VerticalLayout默認爲100%寬度。

集未定義寬度:

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

left.setWidth(null); 
right.setWidth(null); 
相關問題