我想創建BeanTreeView的新節點,當我在構造函數中添加一些節點,然後運行該應用程序,然後我嘗試用樹查看窗口,它拋出這個錯誤爲什麼在此代碼中出現「組件無法創建」錯誤?
java.lang.AssertionError: Component cannot be created for {component=null, displayName=Exploirer, instanceCreate=AlwaysEnabledAction[Exploirer]} at org.openide.windows.OpenComponentAction.getTopComponent(OpenComponentAction.java:71)
爲什麼?以及如何在那裏添加節點?看代碼。
private ProjectsChildren projectsChildren;
private final ExplorerManager mgr = new ExplorerManager();
private ProjectNode projectNode = new ProjectNode(new MainProject("ggg"), projectsChildren);
public ExploirerTopComponent() {
//*****************This is not important code for my problem
initComponents();
setName(NbBundle.getMessage(ExploirerTopComponent.class, "CTL_ExploirerTopComponent"));
setToolTipText(NbBundle.getMessage(ExploirerTopComponent.class, "HINT_ExploirerTopComponent"));
// setIcon(ImageUtilities.loadImage(ICON_PATH, true));
//map.put("delete", ExplorerUtils.actionDelete(mgr, true));
//*******************end of not important code
associateLookup (ExplorerUtils.createLookup(mgr, getActionMap()));
/* somewhere here is the problem*/
mgr.setRootContext(projectNode);
ProjectNode[] pr = null;
pr[0] = projectNode;
mgr.getRootContext().getChildren().add(pr);
}
雅我知道了......我誤解了它......這就是爲什麼我刪除了答案 – RubyDubee 2010-03-26 14:46:15