我是GWT的新手。我想要一个VerticalSplitPanel在左边,一个VerticalSplitPanel在右边,在FlowPanel里面。这使得当尺寸从桌面更改为电话时,右侧的移动到左侧的下方。但是除了我放在FlowPanel之上的一个TabPanel之外,什么也没有显示出来。下面是相关的HTML:
下面是java GWT:
public void onModuleLoad() {
//create TabPanel
final TabPanel tabPanel = new TabPanel();
tabPanel.add(new HTML("Add Watchlist Here"),"Watchlists");
tabPanel.add(new HTML("Add Strategies Here"),"Strategies");
tabPanel.add(new HTML("Add Backtests Here"),"Backtests");
tabPanel.selectTab(0);
RootPanel.get("tabPanel").add(tabPanel);
//create FlowPanel for responsive design to work on small screens
final FlowPanel flowPanel = new FlowPanel();
//create the left VerticalSplitPanel
final VerticalSplitPanel leftVerticalSplitPanel = new VerticalSplitPanel();
leftVerticalSplitPanel.setSize("300px", "500px");
leftVerticalSplitPanel.setSplitPosition("35%");
//add dummy TextArea to left top VerticalSplitPanel
TextArea leftTextAreaTop = new TextArea();
leftTextAreaTop.setVisibleLines(5);
leftTextAreaTop.setText("dummy text to show left top widget");
leftVerticalSplitPanel.setTopWidget(leftTextAreaTop);
//add notes TextArea to left bottom VerticalSplitPanel
TextArea leftTextAreaBottom = new TextArea();
leftTextAreaBottom.setVisibleLines(5);
leftTextAreaBottom.setText("dummy text to show left bottom widget");
leftVerticalSplitPanel.setBottomWidget(leftTextAreaBottom);
//add the left VerticalSplitPanel to the FlowPanel
flowPanel.add(leftVerticalSplitPanel);
//create the right VerticalSplitPanel
final VerticalSplitPanel rightVerticalSplitPanel = new VerticalSplitPanel();
rightVerticalSplitPanel.setSize("300px", "500px");
rightVerticalSplitPanel.setSplitPosition("35%");
//add dummy TextArea to right top VerticalSplitPanel
TextArea rightTextAreaTop = new TextArea();
rightTextAreaTop.setVisibleLines(5);
rightTextAreaTop.setText("dummy text to show right top widget");
rightVerticalSplitPanel.setTopWidget(rightTextAreaTop);
//add notes TextArea to right bottom VerticalSplitPanel
TextArea rightTextAreaBottom = new TextArea();
rightTextAreaBottom.setVisibleLines(5);
rightTextAreaBottom.setText("dummy text to show right bottom widget");
rightVerticalSplitPanel.setBottomWidget(rightTextAreaBottom);
//add the right VerticalSplitPanel to the FlowPanel
flowPanel.add(rightVerticalSplitPanel);
//add the FlowPanel to the RootPanel
RootPanel.get("flowPanel").add(flowPanel);
}注意:我在左边的VerticalSplitPanel中加入了几个TextAreas,希望这能让一些东西显示出来,但没有什么乐趣。有什么建议吗?
编辑:我修复了一个bug,并设置了两个垂直面板的大小。现在,他们中的一些人以一种奇怪的顺序出现。左上角小工具是正确的。缺少左下角小部件。右下角小部件是在下面左上角小工具。右上角小部件是underneath那个!
发布于 2021-02-26 05:47:52
您的代码中有相当多的问题。从不太重要的开始:
rightVerticalSplitPanel为空,因此它将不可见。leftVerticalSplitPanel只有底部小部件,因为您调用setBottomWidget两次(我想应该有setTopWidget对于textAreaTop)leftVerticalSplitPanel(及rightVerticalSplitPanel),例如leftVerticalSplitPanel.setHeight("100px");VerticalSplitPanel已被弃用,并且只能在quirks模式下工作,则应使用SplitLayoutPanel取而代之的是https://stackoverflow.com/questions/66375523
复制相似问题