JavaFX 8:CheckBoxTreeTableCell 样式
JavaFX 8: CheckBoxTreeTableCell styling
我的应用程序中有一个 TreeTableView。根是隐藏的。下一层是组列表,再下面是用户列表。每行都有一个 checkBoxTreeTableCell,允许用户 select 个人用户或他们所属的组(然后 select 组中的所有用户)。
我想要复选框的样式,以便它们适合我的应用程序的配色方案,但我找不到任何关于如何设置它们样式的示例。
通过在我的应用程序 css:
中进行设置,我已经能够在未 selected 时更改它们的颜色
.check-box-tree-table-cell .box {
-fx-background-color: #72BD2D;
}
但是,当 selected 复选框时,我找不到更改颜色的方法。我也无法更改边框、复选标记等的颜色
有没有人有什么想法?
请注意(在将其标记为重复之前)这是一个复选框树-table-单元格 - 而不是复选框-table-单元格。同样,它是树-table-单元格,而不是table-单元格。
编辑:在进一步检查中,class 没有实现样式化,所以我猜这就是导致问题的原因。我很好奇如何使用上面的 CSS 更改复选框的初始颜色,因为它不可设置样式?
在树 table 单元格内只有一个常规复选框,因此您可以像设置任何其他复选框一样设置它的样式。
查看如何在默认 JavaFx 主题中定义复选框(modena.css,搜索 check-box
)。
试试这个例子 css 作为起点:
// container of check box
.tree-table-cell .check-box {
-fx-background-color:pink;
}
// rounded box of check box
.tree-table-cell .check-box .box{
-fx-background-color:green;
}
// checkmark of check box
.tree-table-cell .check-box .box .mark{
-fx-background-color:yellow;
}
//Copied from modena.css
/*******************************************************************************
* *
* CheckBox *
* *
******************************************************************************/
.check-box {
-fx-label-padding: 0.0em 0.0em 0.0em 0.416667em; /* 0 0 0 5 */
-fx-text-fill: -fx-text-background-color;
}
.check-box > .box {
-fx-background-radius: 3, 2, 1;
-fx-padding: 0.166667em 0.166667em 0.25em 0.25em; /* 2 2 3 3 */
}
.check-box > .box > .mark {
-fx-background-color: null;
-fx-padding: 0.416667em 0.416667em 0.5em 0.5em; /* 5 5 6 6 */
-fx-shape: "M-0.25,6.083c0.843-0.758,4.583,4.833,5.75,4.833S14.5-1.5,15.917-0.917c1.292,0.532-8.75,17.083-10.5,17.083C3,16.167-1.083,6.833-0.25,6.083z";
}
.check-box:indeterminate > .box {
-fx-padding: 0;
}
.check-box:indeterminate > .box > .mark {
-fx-shape: "M0,0H10V2H0Z";
-fx-scale-shape: false;
-fx-padding: 0.666667em; /* 16x16 = 8+8 */
}
我的应用程序中有一个 TreeTableView。根是隐藏的。下一层是组列表,再下面是用户列表。每行都有一个 checkBoxTreeTableCell,允许用户 select 个人用户或他们所属的组(然后 select 组中的所有用户)。
我想要复选框的样式,以便它们适合我的应用程序的配色方案,但我找不到任何关于如何设置它们样式的示例。
通过在我的应用程序 css:
中进行设置,我已经能够在未 selected 时更改它们的颜色.check-box-tree-table-cell .box {
-fx-background-color: #72BD2D;
}
但是,当 selected 复选框时,我找不到更改颜色的方法。我也无法更改边框、复选标记等的颜色
有没有人有什么想法?
请注意(在将其标记为重复之前)这是一个复选框树-table-单元格 - 而不是复选框-table-单元格。同样,它是树-table-单元格,而不是table-单元格。
编辑:在进一步检查中,class 没有实现样式化,所以我猜这就是导致问题的原因。我很好奇如何使用上面的 CSS 更改复选框的初始颜色,因为它不可设置样式?
在树 table 单元格内只有一个常规复选框,因此您可以像设置任何其他复选框一样设置它的样式。
查看如何在默认 JavaFx 主题中定义复选框(modena.css,搜索 check-box
)。
试试这个例子 css 作为起点:
// container of check box
.tree-table-cell .check-box {
-fx-background-color:pink;
}
// rounded box of check box
.tree-table-cell .check-box .box{
-fx-background-color:green;
}
// checkmark of check box
.tree-table-cell .check-box .box .mark{
-fx-background-color:yellow;
}
//Copied from modena.css
/*******************************************************************************
* *
* CheckBox *
* *
******************************************************************************/
.check-box {
-fx-label-padding: 0.0em 0.0em 0.0em 0.416667em; /* 0 0 0 5 */
-fx-text-fill: -fx-text-background-color;
}
.check-box > .box {
-fx-background-radius: 3, 2, 1;
-fx-padding: 0.166667em 0.166667em 0.25em 0.25em; /* 2 2 3 3 */
}
.check-box > .box > .mark {
-fx-background-color: null;
-fx-padding: 0.416667em 0.416667em 0.5em 0.5em; /* 5 5 6 6 */
-fx-shape: "M-0.25,6.083c0.843-0.758,4.583,4.833,5.75,4.833S14.5-1.5,15.917-0.917c1.292,0.532-8.75,17.083-10.5,17.083C3,16.167-1.083,6.833-0.25,6.083z";
}
.check-box:indeterminate > .box {
-fx-padding: 0;
}
.check-box:indeterminate > .box > .mark {
-fx-shape: "M0,0H10V2H0Z";
-fx-scale-shape: false;
-fx-padding: 0.666667em; /* 16x16 = 8+8 */
}