import java.awt.*; import java.lang.*; import java.util.*; import java.io.*; import corejava.*; import java.net.*; import java.applet.*; // this function enables textfield interface to accept double value // public class DoubleTextField extends TextField { // constructor : def = value to be displayed, min = min acceptable value, max = max acceptable value, size //= length of interface public DoubleTextField(double def, double min, double max, int size) { super("" + def, size); low = min; high = max; } // return true if the value are between min and max; otherwise return false // public boolean isValid() { double value; try { value = (double)(Format.atof(getText())); if (value < low || value > high) throw new NumberFormatException(); } catch (NumberFormatException e) { requestFocus(); return false; } return true; } // return the value as double from the interface // public double getValue() { return (double)(Format.atof(getText())); } private double low; private double high; }