[英]JavaFX: is it possible to set a background color for an entire TreeView?
I have tried the following with no success: 我尝试了以下方法,但均未成功:
.tree-view {
-fx-skin: "com.sun.javafx.scene.control.skin.TreeViewSkin";
-fx-background-color: green, -fx-control-inner-background;
-fx-background-insets: 0, 1;
}
What I am trying to achieve is to set a blue background for an entire TreeView
except the selected one. 我想要实现的是为除所选对象之外的整个
TreeView
设置一个蓝色背景。 Setting the background on the selected tree item works fine, but changing for the entire tree view does not have any effect. 在选定的树项目上设置背景效果很好,但是更改整个树视图不会产生任何效果。
You can color the individual TreeCell
s by using the .tree-cell
selector: 您可以使用
.tree-cell
选择器为单个TreeCell
.tree-cell
:
.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
}
Produces something like this: 产生这样的东西:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.