Class IntRangeTextField

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, SwingConstants

public class IntRangeTextField extends JTextField
A text field for integer values that can specify a minimum and maximum value. Attempting to release focus with an illegal value will set the value to the minimum or maximum as appropriate rather than allowing the focus to be released.
See Also:
  • Constructor Details

    • IntRangeTextField

      public IntRangeTextField()
    • IntRangeTextField

      public IntRangeTextField(int columns)
  • Method Details

    • getMinimum

      public Integer getMinimum()
      Returns:
      The minimum legal value
    • setMinimum

      public void setMinimum(Integer min)
      Sets the minimum value for the field.
      Parameters:
      min - the minimum value
    • getMaximum

      public Integer getMaximum()
      Returns:
      The maximum legal value
    • setMaximum

      public void setMaximum(Integer max)
      Sets the maximum legal value
      Parameters:
      max - the maximum value
    • getIntVal

      public int getIntVal()
      Parses the text as an int.
      Returns:
      The int value of the text, or zero if the text is not a valid int value
    • getIntVal

      public int getIntVal(int defaultVal)
      Parses the text as an int.
      Parameters:
      defaultVal - The value to return if the text cannot be parsed as an int
      Returns:
      The int value of the text, or the indicated default if the text is not a valid int value
    • setIntVal

      public void setIntVal(int val)
      Sets the text to a string representation of the provided value
      Parameters:
      val - the provided value