1

I need to select rows in JXTreeTable for clicked parent and all of its subnodes. In older Swingx with deprecated JXTreeTable it could be done with TreeSelectionListener. I had listener (mTable is deprecated JXTreeTable):

 mTable.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {    
            public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
                selectionPerformered(evt);
            }
        });

and method selectionPerformed(evt):

private void selectionPerformered(javax.swing.event.TreeSelectionEvent evt) {
        boolean unlock = true;
        TreePath parentPath = evt.getNewLeadSelectionPath();
        if (parentPath != null) {
            ListSelectionModel list = mTable.getSelectionModel();
            TreeNode node = ((TreeNode) (parentPath.getLastPathComponent()));
            if (node.getChildCount() > 0) {
                TreePath path = new TreePath(
                        ((DefaultTreeTableModel) mTable.getTreeTableModel()).getPathToRoot((TreeTableNode) node.getChildAt(0)));
                int begin = mTable.getRowForPath(path);
                path = new TreePath(
                        ((DefaultTreeTableModel) mTable.getTreeTableModel()).getPathToRoot((TreeTableNode) node.getChildAt(node.getChildCount() - 1)));
                int end = mTable.getRowForPath(path);
                list.addSelectionInterval(begin, end);
            }
            unlock = false;
        }
        disableUnlock(unlock);
    }

When I clicked "Components" event was fired few times and with list.addSelectionInterval(begin, end); selection worked fine and looked like this:

good one

But now, with new swingx 1.6, with new JXTreeTable, when I click "Components" in debug mode, this event is fire only once, so the result looks like this :

bad one

For example if I click "admin" program selecting this row and next 3 rows with its children. but if I click "Components" I need to select this row and all rows for children and every child's children. If u know what I mean :) Is it any way to fire this event? Or maybe there's another way to do selection?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Dakarth
  • 83
  • 7
  • this issue was/were solved / answered on this forum a few times, have to combine JTable & JTree selection (its clone from SwingX) better answerrs on SwingX forums, inc. selection & hightlighter – mKorbel Jan 08 '13 at 11:20
  • Also consider [`Outline`](http://codereview.stackexchange.com/a/4447/6692). – trashgod Jan 08 '13 at 11:28
  • might be a bug - please show a SSCCE that demonstrates the problem – kleopatra Jan 08 '13 at 11:42
  • this is just a small part of bigger project, I don't know how to show you working demo. – Dakarth Jan 08 '13 at 12:04

0 Answers0