Top Description Inners Fields Constructors Methods
com.dlsc.unitfx

public abstract Class NumberInputField<T extends Number>

extends CustomTextField
Class Inheritance
Known Direct Subclasses
com.dlsc.unitfx.DoubleInputField, com.dlsc.unitfx.IntegerInputField
Type Parameters
<T>
The type of number.
Imports
com.dlsc.unitfx.util.ControlsUtil, javafx.beans.InvalidationListener, javafx.beans.property.BooleanProperty, .IntegerProperty, .ObjectProperty, .ReadOnlyBooleanProperty, .ReadOnlyBooleanWrapper, .SimpleBooleanProperty, .SimpleIntegerProperty, .SimpleObjectProperty, javafx.css.PseudoClass, javafx.scene.control.TextFormatter, javafx.util.converter.NumberStringConverter, java.lang.reflect.ParameterizedType, java.text.NumberFormat, .ParsePosition, java.util.function.Predicate, .UnaryOperator

Base control to number inputs, defines all base functionality to collect any object whose class is child of Number.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
NumberInputField.NumberStringFilteredConverter

Number string converter that provides a filter for text changes.

Field Summary

Modifier and TypeField and Description
private final BooleanProperty
private final ReadOnlyBooleanWrapper
private final ObjectProperty<T>
private final ObjectProperty<T>
private final IntegerProperty
private final IntegerProperty
private boolean
private final ObjectProperty<Predicate<T>>
private final ObjectProperty<T>

Constructor Summary

AccessConstructor and Description
public
NumberInputField()

Instances a new number input with with null value, no validator and allowing negatives.

Method Summary

Modifier and TypeMethod and Description
public final BooleanProperty

Returns:

The boolean property.
allowNegativesProperty
()

Boolean property that tells the control to allow introducing a negative number.

protected abstract String

Returns:

If the number is null, then return empty string.
convertNumberToText
(T
The number to be converted.
number
)

Converts the input number type object to string.

protected abstract T

Returns:

In case of impossible conversion, return null instead of throwing exception.
convertTextToNumber
(String
The text to be converted.
text
)

Converts the text to the input field number type object.

public final T
public final T
public final int
public final int
public final Predicate<T>
public final T
public final ReadOnlyBooleanProperty

Returns:

The read only boolean property.
invalidProperty
()

Property that indicates whether the value is valid after being validated by validator.

public final boolean
private boolean
public final boolean
private boolean
isInvalidNumber(T number)

private void
private void
private void
public final ObjectProperty<T>

Returns:

The maximum value.
maximumValueProperty
()

The maximum value that can be entered in this field.

public final ObjectProperty<T>

Returns:

The minimum value.
minimumValueProperty
()

The minimum value that can be entered in this field.

public final IntegerProperty

Returns:

The maximum value.
numberOfDecimalsProperty
()

The maximum digits in the decimal part of the number.

public final IntegerProperty

Returns:

The maximum value.
numberOfIntegersProperty
()

The maximum digits in the integer part of the number.

public final void
setAllowNegatives(boolean allowNegatives)

private final void
setInvalid(boolean invalid)

public final void
setMaximumValue(T maximumValue)

public final void
setMinimumValue(T minimumValue)

public final void
setNumberOfDecimals(int numberOfDecimals)

public final void
setNumberOfIntegers(int numberOfIntegers)

public final void
setValidator(Predicate<T> validator)

public final void
setValue(T value)

public final ObjectProperty<Predicate<T>>

Returns:

The property storing the validator predicate.
validatorProperty
()

Stores a validator object for the value converted from text entered.

public final ObjectProperty<T>

Returns:

The number value.
valueProperty
()

The number value representation of the text written.

Inherited from com.dlsc.unitfx.CustomTextField:
createDefaultSkingetLeftgetRightleftPropertyrightPropertysetLeftsetRight

Field Detail

allowNegativesback to summary
private final BooleanProperty allowNegatives
invalidback to summary
private final ReadOnlyBooleanWrapper invalid
maximumValueback to summary
private final ObjectProperty<T> maximumValue
minimumValueback to summary
private final ObjectProperty<T> minimumValue
numberOfDecimalsback to summary
private final IntegerProperty numberOfDecimals
numberOfIntegersback to summary
private final IntegerProperty numberOfIntegers
updatingValueback to summary
private boolean updatingValue
validatorback to summary
private final ObjectProperty<Predicate<T>> validator
valueback to summary
private final ObjectProperty<T> value

Constructor Detail

NumberInputFieldback to summary
public NumberInputField()

Instances a new number input with with null value, no validator and allowing negatives.

Method Detail

allowNegativesPropertyback to summary
public final BooleanProperty allowNegativesProperty()

Boolean property that tells the control to allow introducing a negative number.

Returns:BooleanProperty

The boolean property.

convertNumberToTextback to summary
protected abstract String convertNumberToText(T number)

Converts the input number type object to string.

Parameters
number:T

The number to be converted.

Returns:String

If the number is null, then return empty string.

convertTextToNumberback to summary
protected abstract T convertTextToNumber(String text)

Converts the text to the input field number type object.

Parameters
text:String

The text to be converted.

Returns:T

In case of impossible conversion, return null instead of throwing exception.

getMaximumValueback to summary
public final T getMaximumValue()
getMinimumValueback to summary
public final T getMinimumValue()
getNumberOfDecimalsback to summary
public final int getNumberOfDecimals()
getNumberOfIntegersback to summary
public final int getNumberOfIntegers()
getValidatorback to summary
public final Predicate<T> getValidator()
getValueback to summary
public final T getValue()
invalidPropertyback to summary
public final ReadOnlyBooleanProperty invalidProperty()

Property that indicates whether the value is valid after being validated by validator.

Returns:ReadOnlyBooleanProperty

The read only boolean property.

isAllowNegativesback to summary
public final boolean isAllowNegatives()
isIntegerTypedFieldback to summary
private boolean isIntegerTypedField()
Annotations
@SuppressWarnings:unchecked
isInvalidback to summary
public final boolean isInvalid()
isInvalidNumberback to summary
private boolean isInvalidNumber(T number)
listenForAllowNegativeChangesback to summary
private void listenForAllowNegativeChanges()
listenForTextOrValidationChangesback to summary
private void listenForTextOrValidationChanges()
listenForValueChangesback to summary
private void listenForValueChanges()
maximumValuePropertyback to summary
public final ObjectProperty<T> maximumValueProperty()

The maximum value that can be entered in this field. If this property is set, once the user enters a number greater than this minimum the field becomes invalid and the valueProperty() is set to null.

Returns:ObjectProperty<T>

The maximum value.

minimumValuePropertyback to summary
public final ObjectProperty<T> minimumValueProperty()

The minimum value that can be entered in this field. If this property is set, once the user enters a number lower than this minimum the field becomes invalid and the valueProperty() is set to null.

Returns:ObjectProperty<T>

The minimum value.

numberOfDecimalsPropertyback to summary
public final IntegerProperty numberOfDecimalsProperty()

The maximum digits in the decimal part of the number.

Returns:IntegerProperty

The maximum value.

numberOfIntegersPropertyback to summary
public final IntegerProperty numberOfIntegersProperty()

The maximum digits in the integer part of the number.

Returns:IntegerProperty

The maximum value.

setAllowNegativesback to summary
public final void setAllowNegatives(boolean allowNegatives)
setInvalidback to summary
private final void setInvalid(boolean invalid)
setMaximumValueback to summary
public final void setMaximumValue(T maximumValue)
setMinimumValueback to summary
public final void setMinimumValue(T minimumValue)
setNumberOfDecimalsback to summary
public final void setNumberOfDecimals(int numberOfDecimals)
setNumberOfIntegersback to summary
public final void setNumberOfIntegers(int numberOfIntegers)
setValidatorback to summary
public final void setValidator(Predicate<T> validator)
setValueback to summary
public final void setValue(T value)
validatorPropertyback to summary
public final ObjectProperty<Predicate<T>> validatorProperty()

Stores a validator object for the value converted from text entered. If the value entered is not valid, a pseudo class is added to the field, called ":invalid". This can be used for styling the field to indicate invalid inputs.

Returns:ObjectProperty<Predicate<T>>

The property storing the validator predicate.

valuePropertyback to summary
public final ObjectProperty<T> valueProperty()

The number value representation of the text written.

Returns:ObjectProperty<T>

The number value.

com.dlsc.unitfx back to summary

pack-priv Class NumberInputField.NumberStringFilteredConverter

extends NumberStringConverter
Class Inheritance

Number string converter that provides a filter for text changes.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv UnaryOperator<TextFormatter.Change>
Inherited from javafx.util.converter.NumberStringConverter:
fromStringgetNumberFormattoString

Constructor Detail

NumberStringFilteredConverterback to summary
pack-priv NumberStringFilteredConverter()

Method Detail

getFilterback to summary
pack-priv UnaryOperator<TextFormatter.Change> getFilter()