gpt4 book ai didi

java - 在 JavaFX 中更改树单元格选定的字体颜色

转载 作者:行者123 更新时间:2023-11-28 05:43:03 25 4
gpt4 key购买 nike

我有一个 JavaFX TreeView,我想将选定单元格的字体颜色更改为黑色,使其看起来像一个未选定的单元格。 (我试过 setSelectionModel(null) 但这会引发错误。)如果重要的话,单元格在背景图像上具有透明背景。

CSS:

.tree-view, .tree-cell {
-fx-font: 20px "Segoe Print";
-fx-background-color: transparent;
}

.tree-cell {
-fx-background-color: transparent;
-fx-padding: 0 0 0 0;
-fx-text-fill: #000000;
}

.tree-cell:focused {
-fx-text-fill: #000000;
}

.tree-cell:selected {
-fx-text-fill: #000000;
}

.tree-cell .tree-disclosure-node {
-fx-background-color: transparent;
-fx-padding: 10 10 0 40;
}

.button {
-fx-padding: 0 10 0 10;
}

结果:(“test4”被选中)

Result: ("test4" is selected)

这似乎应该将所选单元格的字体颜色设置为黑色,但它并没有发生。 CSS 文件已加载并正在使用(例如,字体是正确的,我也修改了其他内容),所以这不是问题。

最佳答案

如果你只是想要透明背景并且让选中的单元格与未选中的单元格看起来一样,你可以这样做:

.tree-view {
-fx-text-background-color: black ;
-fx-background-color: transparent ;
-fx-selection-bar: transparent ;
}

关于java - 在 JavaFX 中更改树单元格选定的字体颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37760897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com