Class IntegerTextField
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)
-
Field Summary
Fields inherited from class AbstractIntegerTextField
allFormats, currentFormat -
Constructor Summary
ConstructorsConstructorDescriptionIntegerTextField(int columns) IntegerTextField(int columns, long initialValue) IntegerTextField(int columns, BigInteger initialValue) -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated, for removal: This API element is subject to removal in a future version.voidsetAllowNegativeValues(boolean b) Deprecated, for removal: This API element is subject to removal in a future version.usesetMinValue(BigInteger)insteadvoidsetAllowsHexPrefix(boolean usePrefix) Deprecated, for removal: This API element is subject to removal in a future version.voidDeprecated, for removal: This API element is subject to removal in a future version.voidDeprecated, for removal: This API element is subject to removal in a future version.voidsetMaxValue(BigInteger maxValue) Sets the maximum value.voidsetMinValue(BigInteger minValue) Sets the minimum value.Methods inherited from class AbstractIntegerTextField
addActionListener, addChangeListener, clearSelection, getAllFormats, getComponent, getFormat, getIntValue, getLongValue, getMaxValue, getMinValue, getText, getValue, isInBounds, isSelectTextOnFocusGainedEnabled, removeActionListener, removeChangeListener, requestFocus, selectAll, setAccessibleName, setAutoSwitchMode, setEditable, setEnabled, setFormat, setHorizontalAlignment, setShowNumberMode, setText, setValue, setValue, setValue
-
Constructor Details
-
IntegerTextField
public IntegerTextField() -
IntegerTextField
public IntegerTextField(int columns) -
IntegerTextField
public IntegerTextField(int columns, long initialValue) -
IntegerTextField
-
-
Method Details
-
setMaxValue
Description copied from class:AbstractIntegerTextFieldSets the maximum value. The given value must be greater than 0.- Overrides:
setMaxValuein classAbstractIntegerTextField- Parameters:
maxValue- the value
-
setMinValue
Description copied from class:AbstractIntegerTextFieldSets the minimum value. The given value must be less than or equal to 0.- Overrides:
setMinValuein classAbstractIntegerTextField- Parameters:
minValue- the value
-
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, 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, for removal: This API element is subject to removal in a future version.useAbstractIntegerTextField.getFormat()insteadReturns true if in hex mode, false if in another mode.- Returns:
- true if in hex mode, false if in decimal mode.
-
setAllowsHexPrefix
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, for removal: This API element is subject to removal in a future version.usesetMinValue(BigInteger)insteadSets whether or not negative numbers are accepted.- Parameters:
b- if true, negative numbers are allowed.
-
AbstractIntegerTextField.getFormat()instead