javaswingjtreejxtreetablejtreetable

How to: JTable with collapsible JTree in first column and data in the other columns?


I am somewhat lost at this point: I try to create a JTable that is able to hold some kind of a Tree (JTree?) datastructure in the first column followed by data based on the tree Node in the other columns as illustrated in the following image:

enter image description here

That image shows the structure of my JTree. The red lines indicate the table structur that i would need to realize. Each Node in the Tree should be treatet like a single row in that table, etc. I hope it is clear what i try to achieve.

I tried an aproach like it was discussed here: JTable as a JTree Node and here Put JTable in the JTree but that doesn't fit my needs. I also read about the JXTreeTable from the SwingX project but it seems to be very hard to find any usefull examples. Also many links to solutions like this seem to lead to (no longer existing) sun websites and/or beeing redirected to the oracle site...

It would be awesome if someone could lead me into the right direction and/or provide some exmaple code on how to do this (right).

Any help would be appreciated ;).


Solution

  • Create your own TreeTable component like in the following link : http://www.java2s.com/Code/Java/Swing-Components/JTreeTablecomponent.htm