我想更改蓝色悬停条、悬停文本颜色、文本字体以及默认文本字体。
非常感谢。
-更新-
我只做到了这一点
comboBox.setStyle("-fx-background-image: url('" + ImageUtils.getPath() + "fieldTextBkg.png');"
+ "-fx-text-box-border: transparent;"
+ "-fx-background-color: transparent, transparent, transparent, transparent;"
+ "-fx-text-alignment: center;");
那只是改变展开的菜单。无论我试图修改内部下拉列表,我都无法实现。例如,开始时,蓝色条变为绿色。整个背景从白色变为黑色,文本为 Calibri 字体。
谢谢。
最佳答案
这里有一些解释:
/*Edit The control itself*/
.combo-box{
-fx-background-color:purple;
}
/*Edit Normal Cell color */
.combo-box .list-cell{
-fx-background-color:red;
}
/*Edit Cell Color Only when cursor hover cell */
.combo-box .list-cell:hover{
-fx-background-color:green;
}
/*Edit Cell Color Only when selected */
.combo-box .list-cell:selected{
-fx-background-color:blue;
}
关于JavaFx ComboBox 自定义下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41705014/