File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Show expanded JTree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Show expanded JTree" Watch "Show expanded JTree" New topic

Show expanded JTree

Ezra Exposito
Ranch Hand

Joined: Apr 26, 2001
Posts: 34
By default a JTree is displayed with only the root node
expanded. I would like to display the tree completely
expanded from the start since the most important information
in my app are at the leaf nodes. Any ideas or links to good
resources would be greatly appreciated.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Ezra,
As a quick and dirty approach I would do the following:

Ezra Exposito
Ranch Hand

Joined: Apr 26, 2001
Posts: 34
Thanks a bunch, my tree is now fully expanded when it starts.
One last question:
Within a folder the default is to display the subfolders first and then any leaves. Is it possible to reverse the order so that
the leaves are first and then the folders ?
I agree. Here's the link:
subject: Show expanded JTree
It's not a secret anymore!