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

        elisad created issue -
        elisad made changes -
        Field Original Value New Value
        Attachment CustomTreeTableModel.java [ 45636 ]
        Attachment TestTreeTable.java [ 45637 ]
        kleopatra made changes -
        Assignee kleopatra [ kleopatra ]
        elisad made changes -
        Attachment InsertTreeTableModel.java [ 45653 ]
        Attachment TestTreeTableExample.java [ 45654 ]
        elisad made changes -
        Attachment TestTreeTableExample_UPDATED.java [ 45655 ]
        elisad made changes -
        Comment [ Thank you for your answer

        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", as you suggested, and I'm getting the same problem : "Empty nodes if I try to insert the same node more than once" .
        Please find attached the new code

        Did you face such problem? Is their any way or implementation to avoid such problem? In case, a duplicate node is added don't draw it

        Could you please advise what is the best way to insert at runtime a node into the treetable?

        ]
        elisad made changes -
        Comment [ I've updated the sample "TestTreeTableExample" as below and it is working as expected now in a simple scenario.

          addBtn.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
                if(aNode.getIndex(dNode) == -1) {
                    aNode.insert(dNode, 0);
                    model.getModelSupport().fireChildAdded(new TreePath(model.getPathToRoot(aNode)), aNode.getIndex(dNode), dNode);
                    treeTable.expandRow(0);
                } else {
                    System.out.println("Node already added");
                }
             }
         });

        I would like to know your point of view regarding :
           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 ]
        kleopatra made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.6.3 [ 13366 ]
        Resolution Invalid [ 6 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: