File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes tree display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "tree display" Watch "tree display" New topic
Author

tree display

Narendra kodli
Greenhorn

Joined: Dec 24, 2011
Posts: 22
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

Joined: Jun 09, 2003
Posts: 4632
add a new JTree with the original tree's selection as the root?
Narendra kodli
Greenhorn

Joined: Dec 24, 2011
Posts: 22
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

Joined: May 03, 2008
Posts: 4664
    
    5

To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.

luck, db
There are no new questions, but there may be new answers.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> 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

Joined: Dec 24, 2011
Posts: 22
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

Joined: May 03, 2008
Posts: 4664
    
    5

What are "normal folders"?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> 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

Joined: Oct 16, 2003
Posts: 1096
    
  10

You can use a JTable for the RHS and not necessarily a tree.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Narendra kodli
Greenhorn

Joined: Dec 24, 2011
Posts: 22
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

Joined: Oct 16, 2003
Posts: 1096
    
  10

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).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tree display