aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTree/JScrollpane problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree/JScrollpane problem" Watch "JTree/JScrollpane problem" New topic
Author

JTree/JScrollpane problem

Jerry Crothers
Ranch Hand

Joined: Mar 06, 2001
Posts: 34
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.
Jerry Crothers
Ranch Hand

Joined: Mar 06, 2001
Posts: 34
Sorry typo on this line:

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:

Should be:

Now when I click to collapse the nodes of the child node (UNDER the root) - ie the first line at the top of the window, this code:

Jerry.
 
jQuery in Action, 2nd edition
 
subject: JTree/JScrollpane problem
 
Similar Threads
Subtree in JTree
XML to DOM to JTree
Expanding a Specific Node in JTree
Searching a JTree
JTree + JList in JScrollPane - Out of Sync