0

I have a hierarchy of objects that I would like to show using a JTree and TreeModel. Each level of the hierarchy is a different class.

All the examples of JTree and TreeModel I've seen have a common class throughout the entire hierarchy of the tree (i.e. File for a file system browser). How do you go about implementing TreeModel when your hierarchy changes class from level-to-level? Do you put TreeModel inside TreeModel?

kleopatra
  • 51,061
  • 28
  • 99
  • 211
mark
  • 1,398
  • 13
  • 30
  • do you mean you have a collections of object and you want the collections to display in a TreeModel? – Jasonw Mar 23 '12 at 03:42

1 Answers1

1

Implement TreeModel and then supply your own implementation of methods. JTree works with Objects, so you should be fine with multiple types.

Jakub Zaverka
  • 8,816
  • 3
  • 32
  • 48