Change the size of the JDatePicker Calendar

旧时模样 提交于 2019-12-12 05:39:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!