简体   繁体   English

JavaFx如何隐藏/显示TreeItem

[英]JavaFx How to hide / show TreeItem

I have a TreeItem (a Tree with 100+ TreeItems elements). 我有一个TreeItem(一棵有100多个TreeItems元素的树)。 I want to give the user the ability to hide (or show again) some TreeItems. 我想让用户能够隐藏(或再次显示)某些TreeItem。 (So the user will see just the items he care about). (因此,用户将只看到他关心的项目)。

I cant see a property of TreeItem which give me the ability to show or hide. 我看不到TreeItem的属性,该属性使我能够显示或隐藏。

How can I do it ? 我该怎么做 ?

If you want to show/hide any TreeItem in TreeView you should add or remove it: 如果要在TreeView中显示/隐藏任何TreeItem,则应添加或删除它:

parentTreeItem.getChildren().remove(treeItem);
...
parentTreeItem.getChildren().add(treeItem);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM