posted 18 years ago
I am having a problem using the JTree when using a scroll pane.
Basically after clicking on a child node (under the root) the nodes below that expand, however the scroll bar appears and moves down slightly, so that the child node (of the root) is at the top of the window. The root node is hidden now.
Now when I click to collapse the nodes of the child node (of the root) - ie the first line at the top of the window, this code:
int x = e.getX();
int y = e.getY();
int row = tree.getRowForLocation(x, y);
TreePath path = tree.getPathForRow(row);
TreeNode node = (TreeNode)path.getLastPathComponent();
returns row Zero and the node is the root node (which was actually hidden).
It should be returning row = -1 and then just collapse the tree. Instead the click event on the root node occurs.
Please help......
Jerry.