JavaFX8 treeTableView自定义折叠根项 [英] JavaFX8 treeTableView customize collapse root item
问题描述
如何自定义树根项目的折叠外观?通过自定义我的意思是设置一个图像并将小三角形(/新图像)放在其单元格中。
How can I customize the collapse appearance of a tree root item? By customizing I mean setting an image and center that little triangle(/new image) inside its cell.
提前致谢。
推荐答案
查看默认样式表modena.css,您可以从jre / lib / ext中的jfxrt.jar文件中提取,或者在线查找。图形被定义为那里的路径:
Have a look at the default stylesheet, modena.css, which you can extract from the jfxrt.jar file in jre/lib/ext, or find online. The graphic is defined as a path there:
.tree-cell > .tree-disclosure-node,
.tree-table-row-cell > .tree-disclosure-node {
-fx-padding: 4 6 4 8;
-fx-background-color: transparent;
}
.tree-cell > .tree-disclosure-node > .arrow,
.tree-table-row-cell > .tree-disclosure-node > .arrow {
-fx-background-color: -fx-text-background-color;
-fx-padding: 0.333333em 0.229em 0.333333em 0.229em; /* 4 */
-fx-shape: "M 0 -3.5 L 4 0 L 0 3.5 z";
}
.tree-cell:expanded > .tree-disclosure-node > .arrow,
.tree-table-row-cell:expanded > .tree-disclosure-node > .arrow {
-fx-rotate: 90;
}
您可以在自己的css中覆盖这些规则。
css中引用的箭头是Region,因此如果需要,可以定义 -fx-background-image
。
You can override these rules in your own css.
The arrow referred to in the css is a Region, so you could define a -fx-background-image
if you wanted.
这篇关于JavaFX8 treeTableView自定义折叠根项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!