I have a jtree inside scroll pane. Initially,when the jtree is displayed, a node is preselected. but, since the jtree is big, the selected node is not visible to user at the start. In order to see the selected node, user has to scroll manually. Is there a way to make the scroll pane (or jtree) scroll to the selected node? Thanks.
scrollPane.getViewport().scrollRectToVisible([rectOfTheTreeCell]); (works fine) or maybe: scrollbar.setValue([rowOfTreeCell]); (never tried this last one, though) Chantal
You can use scrollPathToVisible(treePath) method in Tree or ScrollPathToVisible(int row).. you can get TreePath either from Node object itself or From DefaultTreeModel.