我有一个具有多个“根”的 JTree(当然,我实际上有一个不可见的具有多个子节点的真实根)。
节点在双击时展开和折叠,但没有视觉指示表明您可以执行此操作,因为没有展开器图标。
默认情况下树是折叠的,这使情况变得更糟,但扩展“根”并没有真正帮助,因为每个都有很多 child ,看起来很杂乱。
有没有办法显示扩展器图标而不使真正的(完全没有值(value)的)根可见?
欢迎提出任何其他使显示更清晰的建议。
最佳答案
会 tree.setShowsRootHandles(true)
成为good way to display那些“扩展器图标”?
A tree typically also performs some look-and-feel-specific painting to indicate relationships between nodes. You can customize this painting in a limited way.
- First, you can use
tree.setRootVisible(true)
to show the root node or tree.setRootVisible(false) to hide it.- Second, you can use
tree.setShowsRootHandles(true)
to request that a tree's top-level nodes — the root node (if it is visible) or its children (if not) — have handles that let them be expanded or collapsed.
同时检查您的 look and feel确定渲染器对您的树做了什么。
关于java - 有没有办法在 JTree 中为多个根添加扩展器图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/435892/