addNotify not works allright
- by joseph
Hello. I call addNotify() method in class that I posted here. The problem is, that when I call addNotify() as it is in the code, setKeys(objs) do nothing. Nothing appears in my explorer of running app.
But when I call addNotify()without loop(for int....), and add only one item to ArrayList, it shows that one item correctly.
Does anybody knows where can be problem? See the cede
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);
}
}