VerticalSplitPanel不在GWT中显示小部件

时间:2009-08-23 14:44:38

标签: java gwt

这是我用来尝试显示VerticalSplitPanel的一些非常简单的代码,但是我添加的小部件没有显示。 VerticalSplitPanels的分隔符确实显示我添加的小部件没有。

代码:

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

我做错了什么,或者VerticalPanel是非常烦人的错误?

1 个答案:

答案 0 :(得分:1)

我只是尝试了你的代码(通过一个小的调整来修复编译错误)并且它显示了两个小部件。我在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());
}