这就是我创建日期 JSpinner 的方式。当我单击箭头时,它只能将年份减少某个值(二或一)或增加(仅几次)一。我很困惑,请帮助!
Date current = calendar.getTime();
SpinnerDateModel yearsData = new SpinnerDateModel(current,null,null,Calendar.YEAR);
JSpinner years = new JSpinner(yearsData);
years.setEditor(new JSpinner.DateEditor(years, "YYYY"));
JFormattedTextField tfYears = ((JSpinner.DefaultEditor)years.getEditor()).getTextField();
tfYears.setHorizontalAlignment(JTextField.RIGHT);
tfYears.setFont(new Font("SansSerif", Font.PLAIN, 10));