2

I tried every code on StackOverflow to change my combo box prompt text color to #989898, But it not changed and still in black color. Please if you have an idea about that it is very helpful to me. I'll add my CSS file below.

.combo-box
{
    -fx-font-size : 21px;
    -fx-font-family: 'Actor';
    -fx-text-fill : #989898;
    -fx-unfocus-color : #989898;
    -fx-prompt-text-fill: #989898;
}

.jfx-combo-box
{
    -fx-prompt-text-fill: #989898;
}

Here is how its look like, Here you can see my combo box prompt text color changes from other text feilds

kleopatra
  • 51,061
  • 28
  • 99
  • 211
  • for core combos, the prompt text fill is a css property of the combo's editor (see the javafx css spec to what's available) - so the selector should be `.combo-box .text-field`. Don't know if there's anything special in jfoenix – kleopatra Mar 20 '21 at 11:50

1 Answers1

0

One of these should work out:

comboBox.setStyle("-fx-text-fill: #f0f0f0;" +
               "-fx-text-background-color: #f0f0f0;" +
               "-fx-text-inner-color: #f0f0f0;" +
               "-fx-font-weight: bold;" +
               "-fx-fill: #f0f0f0;");

Works for legacy ComboBox, JFoenix and MFX

Also, you can use CSS lookup:

    Node text = comboBox.lookup(".text");
    text.setStyle("-fx-text-fill: #f0f0f0;" +
                                    "-fx-text-background-color: #f0f0f0;" +
                                    "-fx-text-inner-color: #f0f0f0;" +
                                    "-fx-font-weight: bold;" +
                                    "-fx-fill: #f0f0f0;");
    text.setFill(Color.rgb(240, 240, 240));
FARS
  • 313
  • 6
  • 20