javafxdatepicker

Why am I unable to set DatePicker font size?


I developed an javafx application for touch screens. Because of that I set all text fields with a 45px font size:

.text-field{
    -fx-font: 45px "Arial";
}

Now I want to use a normal sized DatePicker but I seem unable to change the font size:

<DatePicker fx:id="dpInitialDate" styleClass="my-date-picker"/>

css file:

.date-picker {
    -fx-font: 15px "Arial";
}

.date-picker.text-field {
    -fx-font: 15px "Arial";
}

.my-date-picker {
    -fx-font: 15px "Arial";
}

.my-date-picker.text-field {
    -fx-font: 15px "Arial";
}

It still presents an 45px font. What am I doing wrong?


Solution

  • You need a space between .my-date-picker and .text-field. You want to select TextFields that are child nodes of the DatePicker control, not nodes that have both a date-picker style class and and text-field style class.