AquaSpinnerUI.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:OpenJSharp 作者:
/**
 * 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) {}
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号