Java8。在我的项目中,我使用了swing组件:com.toedter.calendar
这是扩展JDialog的代码片段;
import com.toedter.calendar.IDateEditor;
import com.toedter.calendar.JDateChooser;
import com.toedter.calendar.JSpinnerDateEditor;
private IDateEditor spinnerDateEditorOpenDate, spinnerDateEditorNextDate;
spinnerDateEditorOpenDate = new JSpinnerDateEditor();
spinnerDateEditorOpenDate.setDateFormatString(defaultFilterDateFormat);
dateAccountOpenDateChooser = GUIFactory.createDateChooser(spinnerDateEditorOpenDate, isRequired);
dateAccountOpenDateChooser.setName(GUIFactory.createEditableName(bsFieldName));
dateAccountOpenDateChooser.setDateFormatString(defaultFilterDateFormat);
bsFieldValue = M2Check.getBSFieldValue(m2Document, bsFieldName);
if (bsFieldValue != null) {
Date date = DateManager.getDateFromFormat(bsFieldValue);
dateAccountOpenDateChooser.setDate(date);
}
panel.add(dateAccountOpenDateChooser, gbcContentPane);
工作正常:
但是当我通过以正确的日期格式(例如 2017.12。)粘贴文本输入日期时,dateAccountOpenDateChooser.getDate()
返回空。
如何处理将文本粘贴到组件JDateChooser
的问题?