本文整理汇总了Java中org.jdesktop.swingx.calendar.DatePickerFormatter.DatePickerFormatterUIResource类的典型用法代码示例。如果您正苦于以下问题:Java DatePickerFormatterUIResource类的具体用法?Java DatePickerFormatterUIResource怎么用?Java DatePickerFormatterUIResource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DatePickerFormatterUIResource类属于org.jdesktop.swingx.calendar.DatePickerFormatter包,在下文中一共展示了DatePickerFormatterUIResource类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEditor
import org.jdesktop.swingx.calendar.DatePickerFormatter.DatePickerFormatterUIResource; //导入依赖的package包/类
/**
* Creates the editor used to edit the date selection. The editor is
* configured with the default DatePickerFormatter marked as UIResource.
*
* @return an instance of a JFormattedTextField
*/
protected JFormattedTextField createEditor() {
JFormattedTextField f = new DefaultEditor(
new DatePickerFormatterUIResource(datePicker.getLocale()));
f.setName("dateField");
// this produces a fixed pref widths, looking a bit funny
// int columns = UIManagerExt.getInt("JXDatePicker.numColumns", null);
// if (columns > 0) {
// f.setColumns(columns);
// }
// that's always 0 as it comes from the resourcebundle
// f.setColumns(UIManager.getInt("JXDatePicker.numColumns"));
Border border = UIManager.getBorder("JXDatePicker.border");
if (border != null) {
f.setBorder(border);
}
return f;
}
示例2: updateFormatLocale
import org.jdesktop.swingx.calendar.DatePickerFormatter.DatePickerFormatterUIResource; //导入依赖的package包/类
private void updateFormatLocale(Locale locale) {
if (locale != null) {
// PENDING JW: timezone?
if (getCustomFormats(datePicker.getEditor()) == null) {
datePicker.getEditor().setFormatterFactory(
new DefaultFormatterFactory(
new DatePickerFormatterUIResource(locale)));
}
}
}
示例3: testPickerFormatterUIResourceCustomLocale
import org.jdesktop.swingx.calendar.DatePickerFormatter.DatePickerFormatterUIResource; //导入依赖的package包/类
/**
* Issue #691-swingx: locale setting not taken.
* Here: test contructor with locale in uiresource.
*/
@Test
public void testPickerFormatterUIResourceCustomLocale() {
Locale locale = Locale.FRENCH;
DatePickerFormatter formatter = new DatePickerFormatterUIResource(locale);
SimpleDateFormat format = (SimpleDateFormat) formatter.getFormats()[0];
String pattern = UIManagerExt.getString("JXDatePicker.longFormat", locale);
assertEquals("format pattern must be same as from localized resource",
pattern, format.toPattern());
}
示例4: testPickerFormatterUIResourceDefaultLocale
import org.jdesktop.swingx.calendar.DatePickerFormatter.DatePickerFormatterUIResource; //导入依赖的package包/类
/**
* Issue #691-swingx: locale setting not taken.
* Here: test empty contructor == default locale in uiresource.
* Adjusted to fix of Issue ??-swingx: use system default format
* if resources for Locale have no JXDatePicker entry
*/
@Test
public void testPickerFormatterUIResourceDefaultLocale() {
DatePickerFormatter formatter = new DatePickerFormatterUIResource();
SimpleDateFormat format = (SimpleDateFormat) formatter.getFormats()[0];
String pattern = UIManagerExt.getString("JXDatePicker.longFormat");
if (pattern != null) {
assertEquals(pattern, format.toPattern());
} else {
LOG.info("can't run test, no datePicker resource entries for Locale " + Locale.getDefault());
}
}
示例5: getCustomFormats
import org.jdesktop.swingx.calendar.DatePickerFormatter.DatePickerFormatterUIResource; //导入依赖的package包/类
/**
* Checks and returns custom formats on the editor, if any.
*
* @param editor the editor to check
* @return the custom formats uses in the editor or null if it had
* used defaults as defined in the datepicker properties
*/
private DateFormat[] getCustomFormats(JFormattedTextField editor) {
DateFormat[] formats = null;
if (editor != null) {
AbstractFormatterFactory factory = editor.getFormatterFactory();
if (factory != null) {
AbstractFormatter formatter = factory.getFormatter(editor);
if (!(formatter instanceof DatePickerFormatterUIResource)) {
formats = ((DatePickerFormatter) formatter).getFormats();
}
}
}
return formats;
}