| Author |
Tree with Listener not working when added to ScrollPane
|
Praveen Kumar Anekalmath
Greenhorn
Joined: Feb 26, 2007
Posts: 18
|
|
Hi, 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); jPanel.add(scrollPane,BorderLayout.CENTER); 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) jTree.getLastSelectedPathComponent();jTree.setToggleClickCount(1); /* if nothing is selected */ if (node == null) return; /* retrive the node that was selected */ Object nodeInfo = node.getUserObject(); if(nodeInfo!=null) { if( nodeInfo.equals(UIProperties.getLocaleText("enterprise"))) { if(CommonRightPanel.jPanelRightMain.getComponentCount() > 0) CommonRightPanel.jPanelRightMain.add(EnterpriseMain.getRightToolBar(),BorderLayout.NORTH); CommonRightPanel.jPanelRightMain.add(EnterpriseMain.getSearchPanel(),BorderLayout.CENTER); 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, jPanel.add(jTree,BorderLayout.CENTER); it works fine...But i need scrollPane to be added... What is the solution for this...Can please anyone help...
|
Praveen
|
 |
 |
|
|
subject: Tree with Listener not working when added to ScrollPane
|
|
|