1

I recently viewed the following code in the context of implementing a JDatePicker in this post.

UtilDateModel model = new UtilDateModel();
//model.setDate(20,04,2014);
// Need this...
Properties p = new Properties();
p.put("text.today", "Today");
p.put("text.month", "Month");
p.put("text.year", "Year");
JDatePanelImpl datePanel = new JDatePanelImpl(model, p);
// Don't know about the formatter, but there it is...
JDatePickerImpl datePicker = new JDatePickerImpl(datePanel, new DateLabelFormatter());

I wanted to know what the properties Keys "text.month" and "text.year" do. I tried implementing this code and say no change when omitting them. Furthermore, I tried searching for a list of Keys in the Properties class and found nothing helpful. Would anyone know what these property keys do or how I could find out if omitting them is acceptable?

Community
  • 1
  • 1
FallDownT
  • 55
  • 1
  • 8
  • Just guessing: maybe this represents a poor-mans solution regarding internalization; meaning: you don't hardcode the string "Today" in your application, because when the application is using a different language, for example German, the "today" field should better say "Heute" (German for "today"). That is the only explanation I can think of (and of course, when the String is still hardcoded in another piece of code, it doesn't help to use a property). – GhostCat Apr 01 '15 at 13:36

1 Answers1

1

These are for internationalization support. The JDateComponentFactory has code to load those from locale-dependent resource bundles in the JDatePicker distribution. I think you're supposed to use the factory instead of the constructor, and let it set up the properties appropriately so you aren't coupled to the key strings they're using.

Andrew Janke
  • 23,508
  • 5
  • 56
  • 85