Class FixedSizeIntegerTextField

java.lang.Object
docking.widgets.textfield.integer.AbstractIntegerTextField
docking.widgets.textfield.FixedSizeIntegerTextField

public class FixedSizeIntegerTextField extends AbstractIntegerTextField
TextField for entering numbers where the values are restricted to those that can be represented by a specific number of bits. For example, if the bit size is eight, signed values must be between -128 and 127 and unsigned values must be between 0 and 255. By default, this class uses all the formats from the IntegerFormat enum class except for signed octal and signed binary.

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

The bitSize can be changed on this field which will cause its min and max values to change to the appropriate values for that bit size and signedness of the current IntegerFormat. Also, if the current value doesn't fit in the new bit size, it will be reset to having no value (textfield is blank).

Internally, values are maintained using BigIntegers so this class can accommodate any bit size desired. There are convenience methods for getting the value as either an int or long. You should only use these convenience methods if you know the current bit size fits in either a int or long respectively.

There are several configuration options as follows:

  • Bit Size - This value must be 1 or greater and determines the minimum and maximum allowed input values when combined with the current format signedness.
  • Use number prefix - If this mode is on, then non-decimal values must be typed with its prefix(i.e., 0x for hex). When requiring non-decimal prefix, the field is permitted to auto switch formats based on the prefix (or lack thereof). When the "use prefix" option is off, the only way to switch formats is to use the built-in 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

    • FixedSizeIntegerTextField

      public FixedSizeIntegerTextField(int columns, int bitSize)
      Constructor
      Parameters:
      columns - the number of character positions for the preferred size of the text field
      bitSize - the initial bit size
    • FixedSizeIntegerTextField

      public FixedSizeIntegerTextField(int columns, int bitSize, long initialValue)
      Constructor
      Parameters:
      columns - the number of character positions for the preferred size of the text field
      bitSize - the initial bit size
      initialValue - the value to initialize the field to
    • FixedSizeIntegerTextField

      public FixedSizeIntegerTextField(int columns, int bitSize, BigInteger initialValue)
      Constructor
      Parameters:
      columns - the number of character positions for the preferred size of the text field
      bitSize - the initial bit size
      initialValue - the value to initialize the field to
  • Method Details

    • setBitSize

      public void setBitSize(int bitSize)
      Sets the bit size for this field, which effectively sets the min and max values for this field when combined with the signedness of the currently selected IntegerFormat.
      Parameters:
      bitSize - the number of bits that will be used to store this value, effectively determining its min and max value
    • getBitSize

      public int getBitSize()
      Returns the current bit size for this field.
      Returns:
      the current bit size for this field
    • setValue

      public void setValue(BigInteger newValue)
      Description copied from class: AbstractIntegerTextField
      Sets the value of the field to the given value. A null value will clear the field.
      Overrides:
      setValue in class AbstractIntegerTextField
      Parameters:
      newValue - the new value or null.
    • setFormat

      public void setFormat(IntegerFormat format)
      Description copied from class: AbstractIntegerTextField
      Sets the format for entering an integer into this field. The current text in the field will change to keep the same numeric value, but in the new input format.
      Overrides:
      setFormat in class AbstractIntegerTextField
      Parameters:
      format - the format for entering an integer into the field.