Problem adding Child in AbstractTreeTableModel
Hello,
I have a AbstractTreeTableModel.
Root
|
Parent
|
Child 1
Adding of any number of parents is working fine. But When I try to add the second child, the child is not shown in the view. But I can see that the CHild 2,... gets inserted into the Model?
Can anyone help me please in resolving this issue?
I searched the forum and I was not able to find anything for AbstractTreeTableModel..
Thanks
Irfaan
# 2
Well, I doubt you are using an AbstractTreeTableModel since ABSTRACT means you can't create an instance of that class. You need to write another class that extends it.
So assuming you are using the DefaultTreModel, you add a node with code like the following:
DefaultTreeModel model = (DefaultTreeModel)tree.getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)model.getRoot();
root.add(new DefaultMutableTreeNode("another_child"));
model.reload(root);
# 4
> Hence, I called fireTreeNodesChanged after adding a child.
Which is correct.
You should not be invoking fireTreeStructureChanged. There is a big difference.