JNumberField extends JSpinner { @Override public void setValue(Object value) { if (value instanceof Number) { final SpinnerNumberModel model = (SpinnerNumberModel) this.getModel(); double number = Double.parseDouble(value.toString()); if (!(model.getMaximum().compareTo(number) >= 0 && model.getMinimum().compareTo(number) <= 0)) throw new IllegalArgumentException(); } super.setValue(value); } JNumberField();  JNumberField(double defaultNumber, double minValue, double maxValue, double increment); @Override void setValue(Object value); @Override Double getValue(); void setColor(Color color);  }
@Test(expected = IllegalArgumentException.class) @Parameters({"Test"}) public void textValueTest(String text) { final JNumberField numberField = new JNumberField(); numberField.setValue(text); }
@Test(expected = IllegalArgumentException.class) @Parameters({"-1"}) public void outOfBoundValueTest(double invalidValue) { final JNumberField numberField = new JNumberField(); numberField.setValue(-1); }