代码之家  ›  专栏  ›  技术社区  ›  Ali

VerticalSplitPanel在GWT中不显示小部件

  •  0
  • Ali  · 技术社区  · 15 年前

    这是一些非常简单的代码,我正在尝试显示一个垂直拆分面板,但我添加的小部件不显示。VerticalSplitPanels的divider功能确实显示了我添加的小部件。

    public class MyView extends Composite
    {
        private VerticalSplitPanel mainPanel=new VerticalSplitPanel();
    
        public CountryFilterView()
        {               
    
            mainPanel.setSize("100%", "100%");
            mainPanel.setSplitPosition("50%");
            // Add some content
            String randomText = "This is some text to show how the contents on either "
                + "side of the splitter flow.   "
                + "This is some text to show how the contents on either "
                + "side of the splitter flow.   "
                + "This is some text to show how the contents on either "
                + "side of the splitter flow.   ";
            mainPanel.setTopWidget(new HTML(randomText));
            mainPanel.setBottomWidget(new HTML(randomText));
            initWidget(mainPanel);
        }
    } 
    

    我是做错了什么,还是垂直面板只是很烦人的小车?

    2 回复  |  直到 15 年前
        1
  •  1
  •   Carnell    15 年前

    我刚刚尝试了你的代码(用一个小的调整来修正编译错误),它同时显示了两个小部件。我在GWT 2.0中试过这个。

    这是我使用的有效代码。注意构造函数名称的不同。

    public class MyView extends Composite
    {
        private VerticalSplitPanel mainPanel=new VerticalSplitPanel();
    
        public MyView()
        {                           
    
            mainPanel.setSize("100%", "100%");
            mainPanel.setSplitPosition("50%");
            // Add some content
            String randomText = "This is some text to show how the contents on either "
                + "side of the splitter flow.   "
                + "This is some text to show how the contents on either "
                + "side of the splitter flow.   "
                + "This is some text to show how the contents on either "
                + "side of the splitter flow.   ";
            mainPanel.setTopWidget(new HTML(randomText));
            mainPanel.setBottomWidget(new HTML(randomText));
            initWidget(mainPanel);
        }
    } 
    

    public void onModuleLoad() {
        RootPanel.get().add(new MyView());
    }