我在這裏發佈的類中調用了addNotify()方法。問題是,當我在代碼中調用addNotify()時,setKeys(objs)什麼也不做。運行應用程序的瀏覽器中沒有顯示任何內容for cycle not works allright
但是,當我調用addNotify()沒有循環(對於int ....),並且只添加一個項目到ArrayList,它顯示正確的一個項目。
有誰知道哪裏會出問題?見割讓
class ProjectsNode extends Children.Keys{
private ArrayList objs = new ArrayList();
public ProjectsNode() {
}
@Override
protected Node[] createNodes(Object o) {
MainProject obj = (MainProject) o;
AbstractNode result = new AbstractNode (new DiagramsNode(), Lookups.singleton(obj));
result.setDisplayName (obj.getName());
return new Node[] { result };
}
@Override
protected void addNotify() {
//this loop causes nothing appears in my explorer.
//but when I replace this loop by single line "objs.add(new MainProject("project1000"));", it shows that one item in explorer
for (int i=0;i==10;i++){
objs.add(new MainProject("project1000"));
}
setKeys (objs);
}
}
重新標記:這個問答真的沒有任何「的NetBeans岬」給它。 – vkraemer 2010-03-22 16:24:32
原來這是爲什麼addNotify不起作用的問題。我在揭示問題的本質之後編輯了標題 – joseph 2010-03-22 16:30:50