Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX: Use custom Node as collapse / expand branch switch for TreeView

Is it possible to replace the expand and collapse arrow of a TreeView with a custom Node / shape (instead of an image)?

like image 376
Jens Piegsa Avatar asked Oct 03 '22 09:10

Jens Piegsa


1 Answers

The -fx-shape css property of the arrows provides basic SVG shapes.

.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
}
like image 100
Uluk Biy Avatar answered Oct 10 '22 01:10

Uluk Biy