Get your CodeRanch badge!*
The moose likes Swing / AWT / SWT and the fly likes Breadth first tree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Breadth first tree" Watch "Breadth first tree" New topic
Author

Breadth first tree

Pat Peg
Ranch Hand

Joined: Feb 04, 2005
Posts: 194
Is it possible to build a jtree that gives you more of a breadth first look? If so, how would I go about implementing this?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Which child nodes (and grandchild nodes etc.) are shown is completely up to the application. You can simply by default show all children of the root, and none of the grandchildren, thus showing the full breadth, and none of the depth.


Ping & DNS - updated with new look and Ping home screen widget
Pat Peg
Ranch Hand

Joined: Feb 04, 2005
Posts: 194
Thank you but that wasn�t exactly what I was looking for. I�ll explain a bit better-I hope. Typically the tree shows depth-first as in a file system. I wish to show breadth-first(Horizontal) as in an organization. I�ve included an example

Typical tree
Root
-A
-A.1
-A.2
-A.2.1
-B
-B.1

What I would like to show is breadth-first

Root
/ \
A B
/ | \
A.1 A.2 B.1
|
A.2.1
I hope that is clearer...
Pat Peg
Ranch Hand

Joined: Feb 04, 2005
Posts: 194
Formatting got a bit messed up...I'll try again
Depth First
Root
-A
-A.1
-A.2
-A.2.1
-B
-B.1

Breadth First
Root
/ \
-A -B
/ | \
-A.1 -A.2 -B.1
|
-A.2.1
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Got it. JTree expands and displays its nodes vertically; you can't change that to a more horizontal view.
Pat Peg
Ranch Hand

Joined: Feb 04, 2005
Posts: 194
That isn't what I wanted to here but it was the thing I expected. No way huh? Well, thanks for letting me know.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Breadth first tree
 
Similar Threads
Tree Question
Flow chart like tree traversing
Swap
If prior UML knowledge is expected
tree interface