[SWINGX-1439] Duplicate nodes in JXTreeTable appearing as "Empty" nodes Created: 26/Apr/11  Updated: 27/Apr/11  Resolved: 27/Apr/11

Status: Resolved
Project: swingx
Component/s: None
Affects Version/s: 1.6.2
Fix Version/s: 1.6.3

Type: Bug Priority: Critical
Reporter: elisad Assignee: kleopatra
Resolution: Invalid Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Java Source File CustomTreeTableModel.java     Java Source File InsertTreeTableModel.java     Java Source File TestTreeTable.java     Java Source File TestTreeTableExample.java     Java Source File TestTreeTableExample_UPDATED.java    


This is about the rendering of a JXTreeTable.

Whenever the same instance of an object is inserted more than once to the tree component of a JXTreeTable, an empty node is being painted for every subsequent insertion.

We are not expecting those empty nodes.
Could you please advise us how to remove those empty nodes?

To reproduce the problem:
1- Run the attached example (TestTreeTable.java)
2- Click on the button "Add node D to A"
3- Expand node "A" to be able to see the added node "D"
4- Click on the button "Add node D to A" again
5- You must be able to see the blank node under node "D"
6- Repeat step 4 to see the problem again

Comment by kleopatra [ 26/Apr/11 ]

looks like a problem in your model implementation - same happens in a plain JTree as well, replace the relevant part

tree = new JTree(model);
getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);

BTW: better let the TreeModelSupport do the notification, that's why it's there

To track it down, first make it work in a plain tree, if it's working there and not in JXTreeTable, you hit a treeTable issue - and we'll dig here

Comment by elisad [ 27/Apr/11 ]

As you already said, using the old model implementation, the problem is also occurring in a "JTree".
Does that mean that their is a bug in the JTree or a bug in the model implementation?

I tried using the "TreeModelSupport" and it is working fine as I implemented it. You can check files [TestTreeTableExample_UPDATED.java and InsertTreeTableModel.java]

Could you please advise :
1. Is their any other way or implementation to avoid such problem?
2. Best way to insert/update/delete at runtime a node into the treetable?

Thank you

Comment by kleopatra [ 27/Apr/11 ]

my guess is the model implementation (JTree is too long around as that a major bug as that would have gone undetected.

As it's not a SwingX related problem, I'm closing this. Please feel free to reopen if all works correctly in a JTree but not in a JXTreeTable.

Well, as much as I love evaluating code and digging - this is a SwingX issue tracker, not a free debug resource for custom code You might want to go to any of the public forums (first a core Swing forum to make your model work in a JTree) to try and get further help.

Hmm ... on a quick glance: it's a tree structure - this implies that each node has exactly one parent (except the root, which has no parent). So you can't add the same node twice ... What you can do is to add the same user-object to different nodes

Thanks for your interest

Generated at Sat Oct 10 13:31:25 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.