/**
* If the spinner's editor is a DateEditor, this selects the field
* associated with the value that is being incremented.
*/
private void select(final JSpinner spinnerComponent) {
final JComponent editor = spinnerComponent.getEditor();
if (!(editor instanceof JSpinner.DateEditor)) return;
final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
final JFormattedTextField ftf = dateEditor.getTextField();
final Format format = dateEditor.getFormat();
Object value;
if (format == null || (value = spinnerComponent.getValue()) == null) return;
final SpinnerDateModel model = dateEditor.getModel();
final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField());
if (field == null) return;
try {
final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value);
if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) {
select(ftf, iterator, DateFormat.Field.HOUR1);
}
} catch (final IllegalArgumentException iae) {}
}
AquaSpinnerUI.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:jdk8u_jdk
作者:
评论列表
文章目录