我已经尝试了以下但没有成功:
.tree-view {
-fx-skin: "com.sun.javafx.scene.control.skin.TreeViewSkin";
-fx-background-color: green, -fx-control-inner-background;
-fx-background-insets: 0, 1;
}
我想要实现的是为整个 TreeView
设置一个蓝色背景,除了选定的那个。为所选树项设置背景效果很好,但更改整个 TreeView 没有任何效果。
最佳答案
您可以使用 .tree-cell
选择器为单个 TreeCell
着色:
.tree-view {
-fx-background-color:lightsteelblue;
}
.tree-cell {
-fx-background-color:lightsteelblue; // Default color
}
.tree-view:focused .tree-cell:filled:selected {
-fx-background-color:indigo; // Focused color
}
.tree-cell:filled:selected{
-fx-background-color:lightcyan; // Unfocused color
}
产生这样的东西:
关于JavaFX:是否可以为整个 TreeView 设置背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42415809/