问题
I'm using JDatePicker to generate the calendar in java swing. I will like to change the font size inside of the calendar.
I have only manage to change the size of the displaying calendar panel but the font size display monday, tuesday, ... failed to become bigger in size.
Please help me with this.
Thanks
回答1:
If you are using this JDatePicker library:
https://sourceforge.net/projects/jdatepicker/
Then you can use JFormattedTextField to create a instance from JDatePicker and to set the font size, have a look at this code:
// Creating Date Model..
UtilDateModel model = new UtilDateModel();
JDatePanelImpl datePanel = new JDatePanelImpl(model);
// Creating Date Picker
JDatePickerImpl datePicker = new JDatePickerImpl(datePanel);
// You can change font of JDatePicker like this:
JFormattedTextField textField = datePicker.getJFormattedTextField();
textField.setFont(new Font("sans-serif", Font.BOLD, 12));
来源:https://stackoverflow.com/questions/47215462/change-the-size-of-the-jdatepicker-calendar