2009-08-23 90 views
0

這是一些非常簡單的代碼,我用它來嘗試顯示VerticalSplitPanel,但是我添加的小部件沒有顯示。 VerticalSplitPanels的分割器不會顯示,但是我添加的小部件沒有。VerticalSplitPanel在GWT中不顯示小部件

代碼:

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只是很煩人的越野車?

回答

0

嘗試在組件配置之前運行initWidget方法。 檢查鏈接SplitPanel problems

+0

不,它仍然是相同的,即使在將initWidget放在一切之前。 – 2009-08-23 18:49:00

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()); 
} 
+0

他們可能已經在新版本中修復了它 – 2009-12-17 20:34:27