Hi there. I am having a slight problem trying to add a JScrollPane to my Jtree. Is it a case that The ScrollPane appears only if it is required, i.e. when the tree has been expanded sufficiently enough so that further space in the panel is required to accomodate this expansion. My code is as follows(just a snippet):
private JTree tree;
private JPanel newPanel;
public addJTree(
String option)
{
super(option);
createTree();
}
public JTree createTree()
{
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Features");
createNodes(top); //this simply adds the children and gives no hassle
tree = new JTree(top);
JScrollPane treeView = new JScrollPane(tree); //no scroll pane appears
treeView.createVerticalScrollBar(); //dont know if this is necessary
return tree;
}
public JPanel getGUI()
{
//create a panel containing the associated Swing component
newPanel = new JPanel();
newPanel.add(tree);
//JScrollPane scroll = new JScrollPane(newPanel);
//newPanel.add(treeView);
return newPanel;
}
Can anyone see the problem. Any help is much appreciated. Thanks Joe