Hi, I need to implement a JTree that loads its children only upon clicking the node. Everything was fine until when I tried to click the icon to expand and collapse, some runtime error (NullPointerException) appears. Is clicking the + icon and double clicking the folder icon in order to expand/collapse the path not the same? Appended is the code. Thanks....sorry, sorta long. Any comment is welcome.
public TreeGUI(Controller controller, String rootString) { //System.out.println("AAAAAAAAAAAAAAAA"); isExpanded = new ArrayList(); ct = controller; rootNode = buildNode(rootString, rootString);
tree_model = new DefaultTreeModel(rootNode);
tree = new JTree(tree_model); tree.putClientProperty("JTree.lineStyle", "Angled"); sp = new JScrollPane(tree); sp.setPreferredSize(new Dimension(500,600)); ct.add(sp); tree.addTreeSelectionListener(this); buildTree(rootNode);