prova ad aggiungere:
codice:
spinAnno.setEditor(new JSpinner.NumberEditor(spinAnno, "#"));
Demo:
codice:
import javax.swing.*;
import java.util.*;
/**
*
* @author Andrea
*/
public class JSpinnerModel extends JFrame {
public JSpinnerModel() {
super("Test JSpinnerModel");
this.setSize(300,60);
GregorianCalendar calendar = new GregorianCalendar();
int annoCorrente = calendar.get(Calendar.YEAR);
SpinnerModel yearModel = new SpinnerNumberModel(annoCorrente, annoCorrente - 10,
annoCorrente + 10, 1);
JSpinner spinAnno = new JSpinner();
spinAnno.setModel(yearModel);
spinAnno.setEditor(new JSpinner.NumberEditor(spinAnno, "#"));
this.getContentPane().add(spinAnno);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main (String[] args) {
new JSpinnerModel();
}
}