swingx
  1. swingx
  2. SWINGX-1439

Duplicate nodes in JXTreeTable appearing as "Empty" nodes

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Invalid
    • Affects Version/s: 1.6.2
    • Fix Version/s: 1.6.3
    • Component/s: None
    • Labels:
      None

      Description

      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

      1. CustomTreeTableModel.java
        1 kB
        elisad
      2. InsertTreeTableModel.java
        0.9 kB
        elisad
      3. TestTreeTable.java
        2 kB
        elisad
      4. TestTreeTableExample_UPDATED.java
        2 kB
        elisad
      5. TestTreeTableExample.java
        2 kB
        elisad

        Activity

        Hide
        kleopatra added a comment -

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

        tree = new JTree(model);
        tree.expandRow(0);
        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

        Show
        kleopatra added a comment - looks like a problem in your model implementation - same happens in a plain JTree as well, replace the relevant part tree = new JTree(model); tree.expandRow(0); 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
        Hide
        elisad added a comment -

        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

        Show
        elisad added a comment - 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
        Hide
        kleopatra added a comment -

        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
        Jeanette

        Show
        kleopatra added a comment - 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 Jeanette

          People

          • Assignee:
            kleopatra
            Reporter:
            elisad
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: