3

Is there a way to change the font of Time4J CalenderPicker in css-style?

I needed a Persian DatePicker in my program so i used Time4J CalenderPicker.

using this code i could change only the font of cells:

CalendarPicker<PersianCalendar> MyDatePicker = CalendarPicker.persianWithSystemDefaults(); 

MyDatePicker.setCellCustomizer(
            (cell, column, row, model, date) -> {
                cell.setStyle("-fx-font-family: MyFont;");
            }
    );

You can see changes in this image

I tried this code but nothing changed:

MyDatePicker.setStyle("-fx-font-family: MyFont;");

But i want to change the font of hole CalendarPicker.

enter image description here

enter image description here

Ahmad
  • 77
  • 5

2 Answers2

2

In order to apply the changes, you need to use the following code and set new css styles for calender picker and applying the customizations.

private CalendarPicker<PersianCalendar> MyDatePicker = CalendarPicker.persianWithSystemDefaults();
MyDatePicker.getStylesheets().add("/MyCSS-Style.css");

The following gif, demonstrates my customizations.

enter image description here

Ahmad
  • 77
  • 5
1

The calendar picker itself is only the combination of a text editor and a popup button (bundled in a HBox). However, the calendar view is another component which pops up if users press the button. And this component whose font you wish to change is not yet publicly accessible (with the exception of the cells via a special customizer).

I agree that this should be more flexible. Therefore I have opened a new issue to track this request for enhancement.

Feel free to fork Time4J and do your experiments and submit a pull request on time4j-github. Actually I am busy with other things but can look deeper then.

Meno Hochschild
  • 38,305
  • 7
  • 88
  • 115
  • Thank you for your response. I found a way myself by which I can customize calendar picker anyway. – Ahmad Apr 03 '19 at 17:45