spinner.setMaximumSize(new Dimension(spinner.getMaximumSize().width, spinner.getMinimumSize().height));
spinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
//stop editing text inside spinner
try {
spinner.commitEdit();
} catch (ParseException pe) {
//if string does not represent a number, return
return;
}
//new number of classes