FileTreeModel多个根 [英] FileTreeModel Multiple Roots
本文介绍了FileTreeModel多个根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在此处使用此代码来创建文件树模型.我希望它浏览文件.如何添加多个根?例如.列出C:/,D:/,E:/.
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.
这篇关于FileTreeModel多个根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文