2012-01-09 141 views
0

我一直在使用Eclipse RCP一段時間。我瀏覽了Vogella的教程,他們很棒。我還閱讀了Addison-Wesley的「Eclipse Rich Client Platform」一書。我已經達到了使用Databinding框架的程度。具體來說,我使用DatabindingContext,WidgetProperties和BeanProperties。我試圖用複選框來使用它。我的代碼如下所示:Eclipse RCP Databinding

widgetValue = WidgetProperties.selection().observe(btnSupplementalPersonnel); 
modelValue = BeanProperties.value(HO.class,"supplementalPersonnel").observe(ho); 
ctx.bindValue(widgetValue, modelValue); 

btnSupplementalPersonnel定義如下:

Button btnSupplementalPersonnel = toolkit.createButton(gClient, "Supplemental Personnel", SWT.CHECK); 

然而,我的代碼,在這一點上拋出一個NullPointerException。我已經通過很多材料來確定問題,但我似乎無法弄清楚。任何幫助將不勝感激。

+0

我覺得問題是什麼。該小部件創建代碼之前正在執行綁定代碼。對不起,麻煩了。 – okello 2012-01-09 07:44:47

+0

寫下這個答案並接受它... – 2012-04-24 14:40:29

回答

0

對不起,我想通了。對我而言,這是sl iness不馴的;綁定代碼甚至在小部件創建代碼之前執行,因此是NullPointerException。下次我會更加小心。