2014-09-30 47 views
0

通常,滾動面板只有一列。如果我需要兩列,我該如何修改我的代碼?如何在GWT中的scrollpanel內創建兩個或更多colums?

ScrollPanel scrollPanel =new ScrollPanel(panel1); 
scrollPanel.setSize("200px","100px"); 
DecoratorPanel decoratorPanel =new DecoratorPanel(); 
decoratorPanel.add(scrollPanel); 
RootPanel.get("gwtContainer").add(panel); 
RootPanel.get("gwtContainer").add(decoratorPanel); 

回答

0

您可以滾動Grid,FlexTable或LayoutPanel,這樣您就可以擁有一個靈活佈局的公共滾動。

LayoutPanel lp = new LayoutPanel(); 
lp.add(whatever1); 
lp.add(whatever2); 

lp.setWidgetLeftWidth(whatever1, 0, Unit.PCT, 50, Unit.PCT); 
lp.setWidgetRightWidth(whatever2, 0, Unit.PCT, 50, Unit.PCT); 

ScrollPanel scrollPanel = new ScrollPanel(lp); 
scrollPanel.setSize("200px", "100px"); 

DecoratorPanel decoratorPanel = new DecoratorPanel(); 
decoratorPanel.add(scrollPanel); 

RootPanel.get("gwtContainer").add(decoratorPanel); 

希望它可以幫助

相關問題