13

When you open a XML in Eclipse, the content can be shown in as a tree structure like

XML tree view

The tree is "embedded" in a table and the content is showed in a seperate column.

This would be very nice to replicate in Swing, not for XML content specifically, but for similar data with tree structure.

UPDATE

I just learned about JTreeTable, but I really need to do this in NetNeans. Should probably have mentioned that, sorry.

Any ideas?

Community
  • 1
  • 1
Theodor
  • 5,536
  • 15
  • 41
  • 55

3 Answers3

15

SwingX has a JXTreeTable, it's based on but much improved over the oldish examples (links to sun code/article) cited by @mKorbel

kleopatra
  • 51,061
  • 28
  • 99
  • 211
  • @kleopatra - For NetBeans, i'm not so sure, see http://stackoverflow.com/questions/5612782/installing-swingx-in-netbeans – Theodor Aug 22 '11 at 07:49
  • @Theodor: repeating myself (the comment I made there) - mixing a beaninfo 0.9.7 with a swingx of 1.6 is _certain_ to pose problems ;-) – kleopatra Aug 22 '11 at 09:33
  • @kleopatra - After some head scratching, JXTreeTable works beautiful. Sorry that I doubted you =) Thank you. – Theodor Aug 24 '11 at 12:49
6

Check the following:

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319
1

You could try subclassing JTable and making your own custom renderer with behavior that adds/removes new rows when you expand/collapse a node.

Seth
  • 5,596
  • 8
  • 42
  • 56
  • 3
    -1 - you tried it? Very unlikely to get anything half-way robust by on-the-fly custom renderers, there's more issues to solve than mere visuals. Though, at it's very base, the typical J/X/TreeTable implementations _do_ have a custom renderer for the hierarchical column :-) – kleopatra Aug 19 '11 at 14:49
  • 2
    +1 I do it this way already, vary fast for large data sets. The renderer has to render the indentation and the collapse/expand icon, too. – xmedeko Oct 24 '12 at 08:14