【发布时间】:2015-04-01 13:30:50
【问题描述】:
我最近在this post 中实现JDatePicker 的上下文中查看了以下代码。
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());
我想知道属性键“text.month”和“text.year”的作用。我尝试实现此代码并在省略它们时说没有更改。此外,我尝试在 Properties 类中搜索 Keys 列表,但没有发现任何帮助。有谁知道这些属性键的作用,或者我如何知道忽略它们是否可以接受?
【问题讨论】:
-
只是猜测:也许这代表了一个关于内化的穷人解决方案;含义:您不会在应用程序中对字符串“Today”进行硬编码,因为当应用程序使用不同的语言(例如德语)时,“today”字段最好显示为“Heute”(德语为“today”)。这是我能想到的唯一解释(当然,当字符串仍然硬编码在另一段代码中时,使用属性无济于事)。
标签: java properties datepicker