여기에 게시 한 클래스에서 addNotify() 메서드를 호출합니다. 문제는 코드에서 addNotify()를 호출 할 때 setKeys (objs)가 아무 것도하지 않는다는 것입니다. 내 앱 탐색기에 아무것도 표시되지 않습니다.에 대한주기가 작동하지 않습니다.
하지만 루프없이 (int ....) addNotify()를 호출하고 하나의 항목 만 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);
}
}
태그 재 지정 :이 질문은 정말 어떤 '넷빈즈 다움'을하지 않았다. – vkraemer
원래 addNotify가 작동하지 않는 이유가 궁금했습니다. 나는 문제의 본질을 밝힌 후에 제목을 편집했다. – joseph