JavaFX:使用自定义节点作为TreeView的折叠/展开分支开关 [英] JavaFX: Use custom Node as collapse / expand branch switch for TreeView

查看:1253
本文介绍了JavaFX:使用自定义节点作为TreeView的折叠/展开分支开关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用自定义节点 / shape替换 TreeView 的展开和折叠箭头(而不是一个图片)?

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

推荐答案

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

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
}

这篇关于JavaFX:使用自定义节点作为TreeView的折叠/展开分支开关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆