I created a form with default NetBeans edito and put a jTree
on it.
It somehow then creates bunch of elements such as "colors", "sports", "food" in there. But it is not in the creation code. Where is it coming from and how can I edit it...
Even if I do jTree1.removeAll();
everything is still there... and non of my code for adding new items to the jTree working.
private void test(java.awt.event.MouseEvent evt) {
//trying to remove all, but it does not remove anything
jTree1.removeAll();
//it does print it in debug meaning that this function is called
System.out.println("qwe");
//create the root node
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
//create the child nodes
DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("Child 1");
DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("Child 2");
//add the child nodes to the root node
root.add(child1);
root.add(child2);
//now how do I add it to the tree?
//???
}
I need to be able to edit jTree
contents at runtime.