package genius.gui.panels; import javax.swing.SpinnerNumberModel; import javax.swing.event.ChangeListener; /** * Just like SpinnerModel but ensures that it works with numbers of type N. This * improves type checking. Useful when you get something out of the model.... * * @param N * the type of the numbers in the model, the number must also * implement Comparable. */ public class SpinnerModel { private SpinnerNumberModel spinmodel; public SpinnerModel(N value, N minimum, N maximum, N stepSize) { spinmodel = new SpinnerNumberModel(value, (Comparable) minimum, (Comparable) maximum, stepSize); } @SuppressWarnings("unchecked") public N getMinimum() { return (N) spinmodel.getMinimum(); } @SuppressWarnings("unchecked") public N getMaximum() { return (N) spinmodel.getMaximum(); } public javax.swing.SpinnerModel getSpinnerModel() { return spinmodel; } @SuppressWarnings("unchecked") public N getValue() { return (N) spinmodel.getValue(); } public void setValue(N value) { spinmodel.setValue(value); } public void addChangeListener(ChangeListener changeListener) { spinmodel.addChangeListener(changeListener); } }