2011-12-12 94 views
0

我開發Eclipse RCP應用程序,並有一個奇怪的問題:SWT樹在Windows XP下不可見

我使用final Shell dialog = new Shell(Display.getCurrent());開達新對話框,並在其中顯示樹(Tree tree_indicators = new Tree(dialog, SWT.None);)。 當我在開發環境(Ubuntu 11.04 64位,GTK)上運行代碼時,一切正常,樹會正確顯示。 當我將應用程序導出到Win32(32位)並在虛擬機(使用VirtualBox)的Windows XP上運行它時,對話框將正確打開,但樹不會顯示。

我也打電話給dialog.pack();,它爲樹保留空間,但它不可見。我不知道問題是什麼,我也沒有得到任何錯誤信息或日誌條目。

你有什麼建議在哪裏尋找解決方案?

謝謝

+0

看到相關的代碼可能有助於發現問題。 – p12t

+0

你的'Tree'中有沒有'TreeItem'?在win32上沒有樹會顯示,直到你在它上面添加一些元素。 –

回答

0

解決了它,這是一個愚蠢的錯誤。 當我充滿了樹我重繪設置爲false,忘了填寫後,將其設置爲true:

// Turn off drawing to avoid flicker 
     t.setRedraw(false); 
     for (Indicator ind : indicators) { 
      TreeItem item = new TreeItem(t, SWT.None); 
      item.setText(ind.getNumber() + " " + ind.getName()); 
      item.setData(ind); 
      // create sub elements 
      for (SubIndicator subInd : ind.getSubIndicators()) { 
       TreeItem child = new TreeItem(item, SWT.None); 
       child.setText(subInd.getNumberString() + " " + subInd.getName()); 
       child.setData(subInd); 
      } 
     } 
     // this one I forgot 
     t.setRedraw(true);