Reputation:
I have downloaded a jDatePicker library and embedded it into my application successfully. This is just a simple jdatepicker.jar file.
I have this simple code to add jDatePicker in my application
public JDatePickerImpl JDatePickerDemo()
{
UtilDateModel model = new UtilDateModel();
model.setDate(1990, 8, 24);
model.setSelected(true);
JDatePanelImpl datePanel = new JDatePanelImpl(model);
JDatePickerImpl datePicker = new JDatePickerImpl(datePanel, new DateLabelFormatter());
return datePicker;
}
this adds jDatePicker in my application
But the fonts in this above textField is very small, i want to increase its font size. How can I do?
I also have a class with it to format date in textfield, may be that can help but I don't know
public class DateLabelFormatter extends AbstractFormatter
{
private String datePattern = "yyyy-MM-dd";
private SimpleDateFormat dateFormatter = new SimpleDateFormat(datePattern);
@Override
public Object stringToValue(String text) throws ParseException {
return dateFormatter.parseObject(text);
}
}
Upvotes: 0
Views: 2660
Reputation: 5435
I have used sourceforge.net/projects/jdatepicker ...
If you unroll the jar from that site, you can inspect the classes and study their public API. Upon doing this, you will see that there's a class called JDatePickerImpl
. Somehwere I assume, you be instantiating this.
Upon creating an instance of this, you'll see that you have access to its internal text field, which is a JFormattedTextField
. From there, you can change its font:
JDatePickerImpl datePicker = new JDatePickerImpl(...);
JFormattedTextField textField = datePicker.getJFormattedTextField();
textField.setFont(new Font("Some-Font-Name", Font.BOLD, 12));
Upvotes: 3
Reputation: 3
Font font = new Font("Courier", Font.BOLD,12);
//set font for JTextField
field.setFont(font);
http://www.java-examples.com/change-font-jtextfield-example
Upvotes: 0