Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tree display

 
Narendra kodli
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I want to know how to display tree node values in another jscrollpane using jsplitpane. for this i need to add tree selection listner, so that when i click on node its contents or child nodes should be displayed in second jscroll pane how to do that???
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add a new JTree with the original tree's selection as the root?
 
Narendra kodli
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply,

I did accordingly and its displaying original tree structure, but i want to display only the node contents on which i click in new jscrollpane. just like we do in windows manage option.
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> but i want to display only the node contents on which i click in new jscrollpane.

just tried it, and it works fine (but didn't use a treeSelectionListener)
 
Narendra kodli
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to display contents of a particular node using jsplitpane containing 2 jscrollpane, 1for tree and another to display node contents . when i click on node in the tree in scrollpane1, contents of only that particular node should be displayed in scrollpane2 not in the form of tree but in the form of normal folders.
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are "normal folders"?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> not in the form of tree but in the form of normal folders.

I'm reading this that you want to display a list of what's immediately under a selected parent,
similar to Windows Explorer clicking on a folder in the left pane, and the folder's contents
are displayed on the right, in list form (one under the other, whether another parent or leaf).

if so, use the tree's model --> getChildrenCount()/getChild() adding each child to a JList,
then add that to the RHS of the splitpane
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a JTable for the RHS and not necessarily a tree.
 
Narendra kodli
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply

ok can use jtable, but i want some more information in getting node values. Mr.Michael Dunn you are right i want exactly the same results. can you elaborate it with some more details??
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Add a TreeSelectionListener
2) In the listener, get the selected node.
3) Get the data from the selected node.
4) Now, update the rhs table model with data (based on the selected node).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic