Class IntegerTextField


public class IntegerTextField extends AbstractIntegerTextField
TextField for entering integer numbers in one of several number formats. By default, this class uses the IntegerFormat.DEC and the IntegerFormat.HEX, but it can be constructed with any of the formats defined in IntegerFormat.

This field does continuous checking, so you can't enter a bad value.

Internally, values are maintained using BigIntegers so this field can contain numbers as large as desired. There are convenience methods for getting the value as either an int or long. If using these convenience methods, you should also set the max allowed value so that users can't enter a value larger than can be represented by the AbstractIntegerTextField.getIntValue() or AbstractIntegerTextField.getLongValue() methods as appropriate.

There are several configuration options as follows:

  • Max value - This value must be positive and will restrict the input to values less than or equal to this value.
  • Min value - This value must be generally be negative and will restrict the input to values greater than or equal to this value. As a special case, the min value can be set to 1.
  • Auto-switch mode - When requiring non-decimal prefix, the field is permitted to auto switch formats based on the prefix (or lack thereof). When the use prefix is off, the only way to switch formats is to use the ctrl-M action.
  • Show the number mode as hint text - If showing number mode is on, the format short name is displayed lightly in the bottom right portion of the text field. See AbstractIntegerTextField.setShowNumberMode(boolean)
  • Constructor Details

    • IntegerTextField

      public IntegerTextField()
    • IntegerTextField

      public IntegerTextField(int columns)
    • IntegerTextField

      public IntegerTextField(int columns, long initialValue)
    • IntegerTextField

      public IntegerTextField(int columns, BigInteger initialValue)
  • Method Details

    • setMaxValue

      public void setMaxValue(BigInteger maxValue)
      Description copied from class: AbstractIntegerTextField
      Sets the maximum value. The given value must be greater than 0.
      Overrides:
      setMaxValue in class AbstractIntegerTextField
      Parameters:
      maxValue - the value
    • setMinValue

      public void setMinValue(BigInteger minValue)
      Description copied from class: AbstractIntegerTextField
      Sets the minimum value. The given value must be less than or equal to 0.
      Overrides:
      setMinValue in class AbstractIntegerTextField
      Parameters:
      minValue - the value
    • setHexMode

      @Deprecated(forRemoval=true, since="12.2") public void setHexMode()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the radix mode to Hex.

      If the field is currently in decimal mode, the current text will be change from displaying the current value from decimal to hex.

    • setDecimalMode

      @Deprecated(forRemoval=true, since="12.2") public void setDecimalMode()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the mode to Decimal.

      If the field is currently in hex mode, the current text will be change from displaying the current value from hex to decimal.

    • isHexMode

      @Deprecated(forRemoval=true, since="12.2") public boolean isHexMode()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns true if in hex mode, false if in another mode.
      Returns:
      true if in hex mode, false if in decimal mode.
    • setAllowsHexPrefix

      @Deprecated(forRemoval=true, since="12.2") public void setAllowsHexPrefix(boolean usePrefix)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets whether on not the field supports the 0x prefix for hex numbers. This method is deprecated since it now supports addition input modes other than hex or decimal. Turning the prefix on for hex will also turn it on for other non-decimal modes as well.

      If 0x is supported, hex numbers will be displayed with the 0x prefix. Also, when typing, you must type 0x first to enter a hex number, otherwise it will only allow digits 0-9. If the 0x prefix option is turned off, then hex numbers are displayed without the 0x prefix and you can't change the decimal/hex mode by typing 0x. The field will either be in decimal or hex mode and the typed text will be interpreted appropriately for the mode.

      Parameters:
      usePrefix - true to use the 0x convention for hex.
    • setAllowNegativeValues

      @Deprecated(forRemoval=true, since="12.2") public void setAllowNegativeValues(boolean b)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets whether or not negative numbers are accepted.
      Parameters:
      b - if true, negative numbers are allowed.