• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JTree and leaf nodes

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Does anyone out there know how to stop a jtree showing it's leaf nodes. I want to create a menu system, similar to a file explorer, but I don't want the tree to display the child nodes, instead I want these to be displayed in a seperate panel.
I have done some searching in the code, and have not been able to come up with anything so any help would be appreciated.
Thanks in advance
Brian
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd think your model is what you want to look at. It tells the View what to display. For example, you probably don't want to display files in the tree, so don't add them to the model. When someone selects a particular directory you can scan it and display all its contents, files and directories, in the next frame.
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I had the following situation
root
-node1
-----node1leaf
-node2
-----node2leaf
-node3
-----node3leaf
I hid the root (it was just my defined starting point to add my nodes).
Each node had the text data that I wanted the user to see and each node had one leaf that contained the nodes IDKey (unique identifier).
Since I didnt need the leaves to be shown, I could restrict this by setting the click count to 0 or -1 (sorry cant remember for sure which one). This prevented the nodes from being expanded, but allowed me to retrieve the code from the leaf (when selected) and then set up another separate screen with the relevant details according to the code.
It might not be the worlds most attractive solution but hey... it works like a beauty.
Chris
[ November 25, 2003: Message edited by: Chris Brat ]
[ November 25, 2003: Message edited by: Chris Brat ]
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic