如何更改 javafx 中 treeitem 展开和折叠箭头的颜色?

How to change the color of treeitem expand and collapse arrow in javafx?

我在处理树视图的树项时遇到了一些问题。 当您有子树项时,会出现展开和折叠图标箭头。 我只知道如何更改此 expand/collapse 图标的背景颜色。 但是我不知道怎么改变箭头的颜色。

.tree-cell .tree-disclosure-node {
    -fx-background-color: #CCCCCC;
}

.tree-cell:expanded .tree-disclosure-node {
     -fx-color: #CCCCCC;
}

有机会改变这个箭头的颜色吗?我不想使用自绘图标。我只想改变箭头的颜色。

根据 TreeViewSkin,披露节点是一个 StackPane,并且有另一个 StackPane 的子节点,样式为 class arrow

如果要更改此节点的默认颜色,只需添加 arrow class 的颜色即可:

.tree-cell > .tree-disclosure-node > .arrow  {
    -fx-background-color: red;
}
.tree-cell:expanded > .tree-disclosure-node > .arrow {
    -fx-background-color: blue;
}