Class ValidatedTextField

All Implemented Interfaces:
CyclerListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, Scrollable, SwingConstants
Direct Known Subclasses:
BigIntegerTextField, DecimalTextField, IntegerTextField

public abstract class ValidatedTextField extends JTextField implements CyclerListener
The base class for all validated text field components. Subclasses are free to validate/reject any type of input, but typically they will all allow only numeric input only and reject any input containing alphabetic characters. Any ValidatedTextField is also capable of being wrapped in a SpinnerField, thus allowing the user to modify the data via the SpinnerField's Cycler component.
See Also:
  • Constructor Details

    • ValidatedTextField

      public ValidatedTextField()
      Constructs a new ValidatedTextField. The number of columns is set to 0.
    • ValidatedTextField

      public ValidatedTextField(int cols)
      Constructs a new ValidatedTextField containing the specified number of columns.
      Parameters:
      columns - the number of columns to use to calculate the preferred width.
  • Method Details

    • getValue

      public abstract Object getValue()
      Used to retrieve the value of component as an Object (Double, Integer) instead of a String (using getText()).
      Returns:
      the numeric value of the component
    • setSpecialChars

      public void setSpecialChars(char[] chars)
      setSpecialChars method saves the special characters set by SIMTextField.These special chars are used for search.
    • getSpecialChars

      public char[] getSpecialChars()
      getSpecialChars method return the special characters array set by SIMTextField.
    • isValidInput

      protected boolean isValidInput(String str)
      This method verifies that the specified string doesn't contain alphabetic characters.
      Returns:
      true if the input contains numeric data only; false otherwise
    • valueChange

      public abstract void valueChange(CyclerEvent e)
      Called when this textfield is embedded in a SpinnerField and the user attempts to increment/decrement the number represented in this textfield.
      Specified by:
      valueChange in interface CyclerListener