Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX 8 DatePicker style

How to change the style of the calendar in the DatePicker in JavaFX 8? I looked in all the default styles in modena file and i don't find the classes of the DatePicker. Anyone knows how to do it? For example, change the header color to blue.

The default style is the following:

enter image description here

like image 676
iconer Avatar asked Oct 27 '14 22:10

iconer


1 Answers

You can find the css for the DatePickercontrol under .date-picker and .date-picker-popup style classes on the modena.css file.

If you want to change the header (I guess you mean the upper pane with Month and Year), this is what you need:

.date-picker-popup > .month-year-pane {
    -fx-padding: 0.588883em 0.5em 0.666667em 0.5em; /* 7 6 8 6 */
    -fx-background-color: derive(-fx-box-border,30%), 
        linear-gradient(to bottom, derive(-fx-base,-3%), 
                                   derive(-fx-base,5%) 50%, 
                                   derive(-fx-base,-3%));
    -fx-background-insets: 0 0 0 0, 0 0 1 0;
}

You just need to add this style class to your css file, and change -fx-base to the color you want.

like image 161
José Pereda Avatar answered Nov 16 '22 19:11

José Pereda