2

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

enter image description here

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

user1803551
  • 12,965
  • 5
  • 47
  • 74
Yusuf
  • 98
  • 2
  • 14

1 Answers1

3

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;
}
wzberger
  • 923
  • 6
  • 15