JavaFX组合框列表样式 [英] JavaFX Combobox List Styling

查看:581
本文介绍了JavaFX组合框列表样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改JavaFX组合框列表的文本颜色,但它似乎不起作用。

I'm trying to change the text color of a JavaFX combobox list but it does not seem to work.

.combo-box .list-cell {
    -fx-text-fill: -fx-my-menu-font-color-highlighted;
}
.combo-box-popup .list-view{
    -fx-background-color: -fx-my-menu-color;
}

.combo-box-popup .list-view .list-cell{
    -fx-text-fill: #ff0000;
    -fx-padding: 4 0 4 5;
    -fx-background-color: -fx-my-menu-color;
}

.combo-box-popup .list-view .list-cell:filled:selected, .combo-box-popup .list-view .list-cell:filled:selected:hover{
    -fx-background-color: -fx-my-menu-color-highlighted;
    -fx-text-fill: -fx-my-menu-font-color-highlighted;
}

.combo-box-popup .list-view .list-cell:filled:hover{
    -fx-background-color: -fx-my-menu-color-highlighted;
    -fx-text-fill: -fx-my-menu-font-color-highlighted;
}

.combo-box-base{
    -fx-background-color: -fx-my-menu-color;
    -fx-padding: 0;
}

返回以下内容:
下拉列表文本不是白色

This returns the following: The Dropdown list text is not white

如何解决此问题?我的CSS知识不是很强。

How do I fix this? My CSS knowledge is not very strong.

推荐答案

以下示例应该可以正常工作 - 如果没有,请从CSS中删除其他条目也影响popop列表。可能另一个条目具有更高的优先级。

Example below should work fine - if not, remove other entries from your CSS which could affect the popop list as well. Possibly another entry has higher priority.

.combo-box-popup .list-cell {    
    -fx-background-color: white;    
    -fx-text-fill: red;
}

增加特异性你也可以尝试下面的设置

to increase the specificity you can also try the setting below

.combo-box-popup > .list-view > .virtual-flow > .clipped-container > .sheet > .list-cell {
        -fx-background-color: white;    
        -fx-text-fill: red;
}

这篇关于JavaFX组合框列表样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆