2014-09-30 46 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); 

希望它可以帮助

相关问题