java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
javafx.scene.control.Control
javafx.scene.control.TextInputControl
javafx.scene.control.TextField
com.dlsc.unitfx.CustomTextField
com.dlsc.unitfx.NumberInputField<T>
- Type Parameters:
T- The type of number.
- All Implemented Interfaces:
javafx.css.Styleable,javafx.event.EventTarget,javafx.scene.control.Skinnable
- Direct Known Subclasses:
DoubleInputField,IntegerInputField
public abstract class NumberInputField<T extends Number> extends CustomTextField
Base control to number inputs, defines all base functionality to collect any object whose class is
child of
Number.-
Property Summary
Properties Type Property Description javafx.beans.property.BooleanPropertyallowNegativesBoolean property that tells the control to allow introducing a negative number.javafx.beans.property.ReadOnlyBooleanPropertyinvalidjavafx.beans.property.ObjectProperty<T>maximumValueThe maximum value that can be entered in this field.javafx.beans.property.ObjectProperty<T>minimumValueThe minimum value that can be entered in this field.javafx.beans.property.IntegerPropertynumberOfDecimalsThe maximum digits in the decimal part of the number.javafx.beans.property.IntegerPropertynumberOfIntegersThe maximum digits in the integer part of the number.javafx.beans.property.ObjectProperty<Predicate<T>>validatorStores a validator object for the value converted from text entered.javafx.beans.property.ObjectProperty<T>valueThe number value representation of the text written.Properties inherited from class javafx.scene.control.TextInputControl
anchor, caretPosition, editable, font, length, promptText, redoable, selectedText, selection, textFormatter, text, undoableProperties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, widthProperties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible -
Nested Class Summary
-
Field Summary
-
Constructor Summary
Constructors Constructor Description NumberInputField() -
Method Summary
Modifier and Type Method Description javafx.beans.property.BooleanPropertyallowNegativesProperty()Boolean property that tells the control to allow introducing a negative number.protected abstract StringconvertNumberToText(T number)Converts the input number type object to string.protected abstract TconvertTextToNumber(String text)Converts the text to the input field number type object.TgetMaximumValue()Gets the value of the property maximumValue.TgetMinimumValue()Gets the value of the property minimumValue.intgetNumberOfDecimals()Gets the value of the property numberOfDecimals.intgetNumberOfIntegers()Gets the value of the property numberOfIntegers.Predicate<T>getValidator()Gets the value of the property validator.TgetValue()Gets the value of the property value.javafx.beans.property.ReadOnlyBooleanPropertyinvalidProperty()booleanisAllowNegatives()Gets the value of the property allowNegatives.booleanisInvalid()Gets the value of the property invalid.javafx.beans.property.ObjectProperty<T>maximumValueProperty()The maximum value that can be entered in this field.javafx.beans.property.ObjectProperty<T>minimumValueProperty()The minimum value that can be entered in this field.javafx.beans.property.IntegerPropertynumberOfDecimalsProperty()The maximum digits in the decimal part of the number.javafx.beans.property.IntegerPropertynumberOfIntegersProperty()The maximum digits in the integer part of the number.voidsetAllowNegatives(boolean allowNegatives)Sets the value of the property allowNegatives.voidsetMaximumValue(T maximumValue)Sets the value of the property maximumValue.voidsetMinimumValue(T minimumValue)Sets the value of the property minimumValue.voidsetNumberOfDecimals(int numberOfDecimals)Sets the value of the property numberOfDecimals.voidsetNumberOfIntegers(int numberOfIntegers)Sets the value of the property numberOfIntegers.voidsetValidator(Predicate<T> validator)Sets the value of the property validator.voidsetValue(T value)Sets the value of the property value.javafx.beans.property.ObjectProperty<Predicate<T>>validatorProperty()Stores a validator object for the value converted from text entered.javafx.beans.property.ObjectProperty<T>valueProperty()The number value representation of the text written.Methods inherited from class com.dlsc.unitfx.CustomTextField
createDefaultSkin, getLeft, getRight, leftProperty, rightProperty, setLeft, setRightMethods inherited from class javafx.scene.control.TextField
alignmentProperty, getAlignment, getCharacters, getClassCssMetaData, getControlCssMetaData, getOnAction, getPrefColumnCount, onActionProperty, prefColumnCountProperty, setAlignment, setOnAction, setPrefColumnCountMethods inherited from class javafx.scene.control.TextInputControl
anchorProperty, appendText, backward, cancelEdit, caretPositionProperty, clear, commitValue, copy, cut, deleteNextChar, deletePreviousChar, deleteText, deleteText, deselect, editableProperty, end, endOfNextWord, executeAccessibleAction, extendSelection, fontProperty, forward, getAnchor, getCaretPosition, getContent, getFont, getLength, getPromptText, getSelectedText, getSelection, getText, getText, getTextFormatter, home, insertText, isEditable, isRedoable, isUndoable, lengthProperty, nextWord, paste, positionCaret, previousWord, promptTextProperty, queryAccessibleAttribute, redo, redoableProperty, replaceSelection, replaceText, replaceText, selectAll, selectBackward, selectedTextProperty, selectEnd, selectEndOfNextWord, selectForward, selectHome, selectionProperty, selectNextWord, selectPositionCaret, selectPreviousWord, selectRange, setEditable, setFont, setPromptText, setText, setTextFormatter, textFormatterProperty, textProperty, undo, undoablePropertyMethods inherited from class javafx.scene.control.Control
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, getBaselineOffset, getContextMenu, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, layoutChildren, setContextMenu, setSkin, setTooltip, skinProperty, tooltipPropertyMethods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthPropertyMethods inherited from class javafx.scene.Parent
getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBoundsMethods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty
-
Property Details
-
value
The number value representation of the text written.- See Also:
getValue(),setValue(T)
-
allowNegatives
public final javafx.beans.property.BooleanProperty allowNegativesPropertyBoolean property that tells the control to allow introducing a negative number.- See Also:
isAllowNegatives(),setAllowNegatives(boolean)
-
validator
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.- See Also:
getValidator(),setValidator(Predicate)
-
invalid
public final javafx.beans.property.ReadOnlyBooleanProperty invalidProperty- See Also:
isInvalid()
-
numberOfIntegers
public final javafx.beans.property.IntegerProperty numberOfIntegersPropertyThe maximum digits in the integer part of the number.- See Also:
getNumberOfIntegers(),setNumberOfIntegers(int)
-
numberOfDecimals
public final javafx.beans.property.IntegerProperty numberOfDecimalsPropertyThe maximum digits in the decimal part of the number.- See Also:
getNumberOfDecimals(),setNumberOfDecimals(int)
-
minimumValue
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 thevalueProperty()is set tonull.- See Also:
getMinimumValue(),setMinimumValue(T)
-
maximumValue
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 thevalueProperty()is set tonull.- See Also:
getMaximumValue(),setMaximumValue(T)
-
-
Constructor Details
-
NumberInputField
public NumberInputField()
-
-
Method Details
-
convertTextToNumber
Converts the text to the input field number type object.- Parameters:
text- The text to be converted.- Returns:
- In case of impossible conversion, return
nullinstead of throwing exception.
-
convertNumberToText
Converts the input number type object to string.- Parameters:
number- The number to be converted.- Returns:
- If the number is
null, then return empty string.
-
valueProperty
The number value representation of the text written.- See Also:
getValue(),setValue(T)
-
getValue
Gets the value of the property value.- Property description:
- The number value representation of the text written.
-
setValue
Sets the value of the property value.- Property description:
- The number value representation of the text written.
-
allowNegativesProperty
public final javafx.beans.property.BooleanProperty allowNegativesProperty()Boolean property that tells the control to allow introducing a negative number.- See Also:
isAllowNegatives(),setAllowNegatives(boolean)
-
isAllowNegatives
public final boolean isAllowNegatives()Gets the value of the property allowNegatives.- Property description:
- Boolean property that tells the control to allow introducing a negative number.
-
setAllowNegatives
public final void setAllowNegatives(boolean allowNegatives)Sets the value of the property allowNegatives.- Property description:
- Boolean property that tells the control to allow introducing a negative number.
-
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.- See Also:
getValidator(),setValidator(Predicate)
-
getValidator
Gets the value of the property validator.- Property description:
- 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.
-
setValidator
Sets the value of the property validator.- Property description:
- 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.
-
invalidProperty
public final javafx.beans.property.ReadOnlyBooleanProperty invalidProperty()- See Also:
isInvalid()
-
isInvalid
public final boolean isInvalid()Gets the value of the property invalid. -
numberOfIntegersProperty
public final javafx.beans.property.IntegerProperty numberOfIntegersProperty()The maximum digits in the integer part of the number.- See Also:
getNumberOfIntegers(),setNumberOfIntegers(int)
-
getNumberOfIntegers
public final int getNumberOfIntegers()Gets the value of the property numberOfIntegers.- Property description:
- The maximum digits in the integer part of the number.
-
setNumberOfIntegers
public final void setNumberOfIntegers(int numberOfIntegers)Sets the value of the property numberOfIntegers.- Property description:
- The maximum digits in the integer part of the number.
-
numberOfDecimalsProperty
public final javafx.beans.property.IntegerProperty numberOfDecimalsProperty()The maximum digits in the decimal part of the number.- See Also:
getNumberOfDecimals(),setNumberOfDecimals(int)
-
getNumberOfDecimals
public final int getNumberOfDecimals()Gets the value of the property numberOfDecimals.- Property description:
- The maximum digits in the decimal part of the number.
-
setNumberOfDecimals
public final void setNumberOfDecimals(int numberOfDecimals)Sets the value of the property numberOfDecimals.- Property description:
- The maximum digits in the decimal part of the number.
-
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 thevalueProperty()is set tonull.- See Also:
getMinimumValue(),setMinimumValue(T)
-
getMinimumValue
Gets the value of the property minimumValue.- Property description:
- 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 tonull.
-
setMinimumValue
Sets the value of the property minimumValue.- Property description:
- 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 tonull.
-
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 thevalueProperty()is set tonull.- See Also:
getMaximumValue(),setMaximumValue(T)
-
getMaximumValue
Gets the value of the property maximumValue.- Property description:
- 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 tonull.
-
setMaximumValue
Sets the value of the property maximumValue.- Property description:
- 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 tonull.
-