JavaFX:使用自定义节点作为TreeView的折叠/展开分支开关

Jen*_*gsa 5 java javafx-2 fxml javafx-8

是否可以TreeView用自定义Node/形状(而不是图像)替换a的展开和折叠箭头?

Ulu*_*Biy 4

-fx-shape箭头的 css 属性提供了基本的 SVG 形状。

.tree-cell .tree-disclosure-node .arrow {
    -fx-background-color: -fx-mark-color;
    -fx-padding: 0.333333em; /* 4 */
    -fx-shape: "M 0 -4 L 8 0 L 0 4 z";    // <-- change this default triangle shape
}

.tree-cell:expanded .tree-disclosure-node .arrow {
    -fx-rotate: 90;                      // maybe another svg shape instead
}
Run Code Online (Sandbox Code Playgroud)