Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-09-2008, 07:34 AM
Member
 
Join Date: Jan 2008
Posts: 6
praveen.kb is on a distinguished road
Tree with Listener not working when added to ScrollPane
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("enterp rise")))
{
if(CommonRightPanel.jPanelRightMain.getComponentCo unt() > 0)
{
CommonRightPanel.jPanelRightMain.add(EnterpriseMai n.getRightToolBar(),BorderLayout.NORTH);
CommonRightPanel.jPanelRightMain.add(EnterpriseMai n.getSearchPanel(),BorderLayout.CENTER);
CommonRightPanel.jPanelRightMain.add(EnterpriseMai n.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...
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-09-2008, 07:54 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,141
hardwired is on a distinguished road
You may have some layout problems. It's hard to tell without seeing how you put things together. When you add/remove/change components in a container you need to tell the container to validate itself. You can do this with the Container method validate or the JComponent method revalidate.
The TreeSelectionListener will only receive events when the tree selection has changed.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-09-2008, 08:06 AM
Member
 
Join Date: Jan 2008
Posts: 6
praveen.kb is on a distinguished road
Thank you very much hardwired... It works...
I tried putting
CommonRightPanel.jPanelRightMain.validate();
and it works...
Thanks to Java Forums
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
No datas in added to arraylist Preethi New To Java 0 02-15-2008 12:07 PM
Listener for SWT event Java Tip Java Tips 0 01-08-2008 10:04 AM
how to refresh the table when a new account is added and display instantly sravanthi narra SWT / JFace 4 01-05-2008 08:39 PM
Listener collision on game cachi Java Applets 1 08-07-2007 08:48 AM
add an undo listener to a Jtable christina Advanced Java 1 08-06-2007 08:49 PM


All times are GMT +3. The time now is 02:21 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org