JavaFX choicebox text color


Question

Iam trying to change the TextColor of an ChoiceBox in JavaFX.

This is my css file:

.choice-box{
      -fx-background-color: 
        #000000,
        linear-gradient(#7ebcea, #2f4b8f),
        linear-gradient(#426ab7, #263e75),
        linear-gradient(#395cab, #223768);
    -fx-padding: 3 10 4 20;
    -fx-text-fill: white;
    -fx-font-size: 12px;
}

And this is a screenshot of my choice-box:

enter image description here

-fx-text-fill: white; works on buttons but not on choic boxes. Why?

How can i change the color of the text in the choicebox?

1
3
11/13/2013 3:10:18 PM

Accepted Answer

i think you can do:

.choice-box .label {
     -fx-text-fill: white; 
}
5
11/29/2013 10:31:54 AM

You should give these properties to the listcell and not the choice-box. Refer this : http://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#labeled

Hope it helps


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon