Multi Dimensional array to JTree in java

514 Views Asked by At

i want to assign a multidimensional array to jtree. how can i do this?

here is sample of an array:

ROOT:{ FolderA : {FileA,FileB} , FolderB: {FileA,FileB} } ....

Also i want to determine files and assign icon to them.

2

There are 2 best solutions below

0
lukastymo On BEST ANSWER

You must get model from your jtree and then operate on it. Here you have working example

0
trashgod On

Here's a nice article showing how to use org.netbeans.swing.outline.Outline for this. There's more in this answer. Ordinary extensions of TableCellRenderer or the RenderDataProvider interface make it especially easy to customize the appearance of rows in the tree.