I use this code here to create a file tree model. I want it to browse files. How can I add multiple roots? E.g. list C:/, D:/, E:/.
A TreeModel
can only have one root node, but you can use JTree.setRootVisible()
to hide the root node when displaying the tree. Modify your model to have a virtual root node that contains each filesystem root (C:\, D:\, E:\, etc.), and call JTree.setRootVisible(false)
on your JTree.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With