Auto scroll when a JTree's node expand
I have JSplitPane, where the left panel is a JScrollPane with a JTree
inside, and the right panel is a JTable.
This is supposed to be something like the windows explorer, where I
have a tree representing folders on the left and the children listed
on the right. That way, when I double click a node on the right, the
node representing it should expand on the tree and get selected.
This part is working fine, but when I expand a node which is too deep
in the tree, it gets hidden. I'd like to auto scroll the bar, so the
selected node would be visible.
Anybody knows how can I do that? I hope I didn't make it too confusing
thanks in advance for any help.
Re: Auto scroll when a JTree's node expand
On Jul 10, 7:16 pm, Allan Valeriano <allvaleri...@gmail.com> wrote:
> This part is working fine, but when I expand a node which is too deep
> in the tree, it gets hidden. I'd like to auto scroll the bar, so the
> selected node would be visible.
> Anybody knows how can I do that? I hope I didn't make it too confusing
> to understand.
JTree has a method for this. Read the API documentation.
Here is the code
DefaultMutableTreeNode top=new DefaultMutableTreeNode("Table of contents");
JTree tree = new JTree(top);
JScrollPane treeView = new JScrollPane(tree);
treeView.setBounds(as you wish);
|All times are GMT. The time now is 10:33 PM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.