package SesameGUI; public class FloatField extends ValidatedField { public FloatField(float defaultValue, int size) { super("" + defaultValue, size); } public boolean isValid() { boolean ret; String value; value = this.getText(); ret = false; try { float f; f = Float.parseFloat(value); if (f >= minVal && f <= maxVal) ret = true; } catch (NumberFormatException e) { } return ret; } public float getMinVal() { return minVal; } public void setMinVal(float minVal) { this.minVal = minVal; } public float getMaxVal() { return maxVal; } public void setMaxVal(float maxVal) { this.maxVal = maxVal; } public boolean isBiggerThan(ValidatedField other) { boolean ret; ret = false; try { String value, valueRhs; value = this.getText(); valueRhs = other.getText(); if (Float.parseFloat(value) > Float.parseFloat(valueRhs)) ret = true; } catch (NumberFormatException e) { } return ret; } private float minVal; private float maxVal; }