[英]JavaFX: is it possible to set a background color for an entire TreeView?
我嘗試了以下方法,但均未成功:
.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
設置一個藍色背景。 在選定的樹項目上設置背景效果很好,但是更改整個樹視圖不會產生任何效果。
您可以使用.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
}
產生這樣的東西:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.