Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tree with Listener not working when added to ScrollPane

Praveen Kumar Anekalmath
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to add a scrollpane to tree so that on expansion of the tree, scroll bar comes.I'm using the following code:

JSscrollPane = new JScrollPane(jTree);

By doing so,i'm able to see scroll bar when tree expands. But the listener added for tree is not working.Below is the code adding listener:

jTree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e)
DefaultMutableTreeNode node = (DefaultMutableTreeNode)
/* if nothing is selected */
if (node == null) return;
/* retrive the node that was selected */
Object nodeInfo = node.getUserObject();
if( nodeInfo.equals(UIProperties.getLocaleText("enterprise")))
if(CommonRightPanel.jPanelRightMain.getComponentCount() > 0)
CommonRightPanel.jPanelRightMain.add(EnterpriseMain.getSearchDisplayPanel(), BorderLayout.SOUTH);


As in code above, i'm trying to add some panels in the rightPanel of the window, its not happening but Listener is working fine as i added sysout statement.
Instead of adding jTree to scrollPane,if i add jTree to jPanel say like this,

it works fine...But i need scrollPane to be added...
What is the solution for this...Can please anyone help...
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic