- All Implemented Interfaces:
Styleable,EventTarget,Skinnable
Spinner with a modern UI.
The spinner can work on any object you want but you will have to implement your own
SpinnerModel. MaterialFX just like JavaFX offers 4 default models for: doubles,
integers, local dates and lists.
Without a SpinnerModel the spinner is useless!
MFXSpinner offers the following features:
- You can set a prompt text for the field, promptTextProperty()
- You can set the spinner to be editable or not, editableProperty()
- You can allow/disallow the selection of the text, selectableProperty()
- You can specify the action to run when the spinner is editable and ENTER is pressed,
onCommitProperty()
You can specify a function to transform the spinner's text. This can be useful for example when you want to add unit of measures to the text. The function carries the focus state of the editor (this way you can remove/add text according to the focus state) and the T value converted to a String
- You can easily change the orientation of the spinner, orientationProperty()
- You can easily change the icons, prevIconSupplierProperty(), nextIconSupplierProperty()
- You can specify the gap between the text and the icon, graphicTextGapProperty()
-
Property Summary
PropertiesTypePropertyDescriptionSpecifies whether the spinner's text field is editable.Specifies the space between the spinner's text and the two icons.TheSupplierused to build the icons which should triggerSpinnerModel.next().Specifies the action to perform when editing the spinner's text and confirming the changes by pressing ENTER.Specifies the spinner's orientation.TheSupplierused to build the icons which should triggerSpinnerModel.previous().Specifies the prompt text for the spinner's text field.Specifies whether the spinner's text is selectable.Specifies the spinner's model, responsible for handling the spinner's value according to the data type.The text transformer is aBiFunctionthat allows you to change the spinner's text when the spinner's text field acquires/loses focus.Specifies the current selected value for the spinner.Properties inherited from class javafx.scene.control.Control
contextMenu, skin, tooltipProperties 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.Parent
needsLayoutProperties 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 -
Field Summary
Fields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZEFields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidIf the spinner is editable,editableProperty(), pressing the ENTER key will trigger the action specified byonCommitProperty().protected Skin<?>voidRestores the defaults forprevIconSupplierProperty()andnextIconSupplierProperty().Specifies whether the spinner's text field is editable.doubleGets the value of the property graphicTextGap.Gets the value of the property nextIconSupplier.Gets the value of the property onCommit.Gets the value of the property orientation.Gets the value of the property prevIconSupplier.Gets the value of the property promptText.Gets the value of the property spinnerModel.Gets the value of the property textTransformer.getValue()Gets the value of the property value.Specifies the space between the spinner's text and the two icons.booleanGets the value of the property editable.booleanGets the value of the property selectable.TheSupplierused to build the icons which should triggerSpinnerModel.next().Specifies the action to perform when editing the spinner's text and confirming the changes by pressing ENTER.Specifies the spinner's orientation.TheSupplierused to build the icons which should triggerSpinnerModel.previous().Specifies the prompt text for the spinner's text field.Specifies whether the spinner's text is selectable.voidsetEditable(boolean editable) Sets the value of the property editable.voidsetGraphicTextGap(double graphicTextGap) Sets the value of the property graphicTextGap.voidsetNextIconSupplier(Supplier<Node> nextIconSupplier) Sets the value of the property nextIconSupplier.voidsetOnCommit(Consumer<String> onCommit) Sets the value of the property onCommit.voidsetOrientation(Orientation orientation) Sets the value of the property orientation.voidsetPrevIconSupplier(Supplier<Node> prevIconSupplier) Sets the value of the property prevIconSupplier.voidsetPromptText(String promptText) Sets the value of the property promptText.voidsetSelectable(boolean selectable) Sets the value of the property selectable.voidsetSpinnerModel(SpinnerModel<T> spinnerModel) Sets the value of the property spinnerModel.voidsetTextTransformer(BiFunction<Boolean, String, String> textTransformer) Sets the value of the property textTransformer.voidSets the value of the property value.Specifies the spinner's model, responsible for handling the spinner's value according to the data type.The text transformer is aBiFunctionthat allows you to change the spinner's text when the spinner's text field acquires/loses focus.Specifies the current selected value for the spinner.Methods inherited from class javafx.scene.control.Control
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getClassCssMetaData, getContextMenu, getControlCssMetaData, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, layoutChildren, queryAccessibleAttribute, 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, 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, visiblePropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface javafx.css.Styleable
getStyleableNode
-
Property Details
-
value
Specifies the current selected value for the spinner.Note that this property is read-only, you can set the value with
setValue(Object)but it will fail with an exception if thespinnerModelProperty()is null.- See Also:
-
spinnerModel
Specifies the spinner's model, responsible for handling the spinner's value according to the data type. -
promptText
Specifies the prompt text for the spinner's text field.- See Also:
-
editable
Specifies whether the spinner's text field is editable.If you edit the text you must confirm the change by pressing the ENTER key, this will trigger the
commit(String)method, more info hereonCommitProperty().- See Also:
-
selectable
Specifies whether the spinner's text is selectable.- See Also:
-
onCommit
Specifies the action to perform when editing the spinner's text and confirming the changes by pressing ENTER.The action is a
Consumerwhich carries the modified text. To change the spinner's value with that for example you probably want to validate the text, parse a valid T object and then set the value.- See Also:
-
textTransformer
The text transformer is aBiFunctionthat allows you to change the spinner's text when the spinner's text field acquires/loses focus.This can be useful for example when you want to add the unit of measure to the spinner's text. Usually in such controls the unit of measure is added when the control is not focused and removed when editing the text.
An example could be:MFXSpinner spinner = ...; spinner.setTextTransformer((focused, text) -> (!focused || !spinner.isEditable()) ? text + " meters" : text); -
orientation
Specifies the spinner's orientation.- See Also:
-
prevIconSupplier
TheSupplierused to build the icons which should triggerSpinnerModel.previous().Note that the
defaultIcons()add the needed event handlers to use theSpinnerModel, it is not handled automatically! -
nextIconSupplier
TheSupplierused to build the icons which should triggerSpinnerModel.next().Note that the
defaultIcons()add the needed event handlers to use theSpinnerModel, it is not handled automatically! -
graphicTextGap
Specifies the space between the spinner's text and the two icons.- See Also:
-
-
Constructor Details
-
MFXSpinner
public MFXSpinner() -
MFXSpinner
-
-
Method Details
-
defaultIcons
public void defaultIcons()Restores the defaults forprevIconSupplierProperty()andnextIconSupplierProperty(). -
commit
If the spinner is editable,editableProperty(), pressing the ENTER key will trigger the action specified byonCommitProperty(). -
createDefaultSkin
- Overrides:
createDefaultSkinin classControl
-
getUserAgentStylesheet
- Overrides:
getUserAgentStylesheetin classRegion
-
getValue
Gets the value of the property value.- Property description:
- Specifies the current selected value for the spinner.
Note that this property is read-only, you can set the value with
setValue(Object)but it will fail with an exception if thespinnerModelProperty()is null.
-
valueProperty
Specifies the current selected value for the spinner.Note that this property is read-only, you can set the value with
setValue(Object)but it will fail with an exception if thespinnerModelProperty()is null.- See Also:
-
setValue
Sets the value of the property value.- Property description:
- Specifies the current selected value for the spinner.
Note that this property is read-only, you can set the value with
setValue(Object)but it will fail with an exception if thespinnerModelProperty()is null.
-
getSpinnerModel
Gets the value of the property spinnerModel.- Property description:
- Specifies the spinner's model, responsible for handling the spinner's value according to the data type.
-
spinnerModelProperty
Specifies the spinner's model, responsible for handling the spinner's value according to the data type. -
setSpinnerModel
Sets the value of the property spinnerModel.- Property description:
- Specifies the spinner's model, responsible for handling the spinner's value according to the data type.
-
getPromptText
Gets the value of the property promptText.- Property description:
- Specifies the prompt text for the spinner's text field.
-
promptTextProperty
Specifies the prompt text for the spinner's text field.- See Also:
-
setPromptText
Sets the value of the property promptText.- Property description:
- Specifies the prompt text for the spinner's text field.
-
isEditable
public boolean isEditable()Gets the value of the property editable.- Property description:
- Specifies whether the spinner's text field is editable.
If you edit the text you must confirm the change by pressing the ENTER key, this will trigger the
commit(String)method, more info hereonCommitProperty().
-
editableProperty
Specifies whether the spinner's text field is editable.If you edit the text you must confirm the change by pressing the ENTER key, this will trigger the
commit(String)method, more info hereonCommitProperty().- See Also:
-
setEditable
public void setEditable(boolean editable) Sets the value of the property editable.- Property description:
- Specifies whether the spinner's text field is editable.
If you edit the text you must confirm the change by pressing the ENTER key, this will trigger the
commit(String)method, more info hereonCommitProperty().
-
isSelectable
public boolean isSelectable()Gets the value of the property selectable.- Property description:
- Specifies whether the spinner's text is selectable.
-
selectableProperty
Specifies whether the spinner's text is selectable.- See Also:
-
setSelectable
public void setSelectable(boolean selectable) Sets the value of the property selectable.- Property description:
- Specifies whether the spinner's text is selectable.
-
getOnCommit
Gets the value of the property onCommit.- Property description:
- Specifies the action to perform when editing the spinner's text
and confirming the changes by pressing ENTER.
The action is a
Consumerwhich carries the modified text. To change the spinner's value with that for example you probably want to validate the text, parse a valid T object and then set the value.
-
onCommitProperty
Specifies the action to perform when editing the spinner's text and confirming the changes by pressing ENTER.The action is a
Consumerwhich carries the modified text. To change the spinner's value with that for example you probably want to validate the text, parse a valid T object and then set the value.- See Also:
-
setOnCommit
Sets the value of the property onCommit.- Property description:
- Specifies the action to perform when editing the spinner's text
and confirming the changes by pressing ENTER.
The action is a
Consumerwhich carries the modified text. To change the spinner's value with that for example you probably want to validate the text, parse a valid T object and then set the value.
-
getTextTransformer
Gets the value of the property textTransformer.- Property description:
- The text transformer is a
BiFunctionthat allows you to change the spinner's text when the spinner's text field acquires/loses focus.This can be useful for example when you want to add the unit of measure to the spinner's text. Usually in such controls the unit of measure is added when the control is not focused and removed when editing the text.
An example could be:MFXSpinner spinner = ...; spinner.setTextTransformer((focused, text) -> (!focused || !spinner.isEditable()) ? text + " meters" : text);
-
textTransformerProperty
The text transformer is aBiFunctionthat allows you to change the spinner's text when the spinner's text field acquires/loses focus.This can be useful for example when you want to add the unit of measure to the spinner's text. Usually in such controls the unit of measure is added when the control is not focused and removed when editing the text.
An example could be:MFXSpinner spinner = ...; spinner.setTextTransformer((focused, text) -> (!focused || !spinner.isEditable()) ? text + " meters" : text); -
setTextTransformer
Sets the value of the property textTransformer.- Property description:
- The text transformer is a
BiFunctionthat allows you to change the spinner's text when the spinner's text field acquires/loses focus.This can be useful for example when you want to add the unit of measure to the spinner's text. Usually in such controls the unit of measure is added when the control is not focused and removed when editing the text.
An example could be:MFXSpinner spinner = ...; spinner.setTextTransformer((focused, text) -> (!focused || !spinner.isEditable()) ? text + " meters" : text);
-
getOrientation
Gets the value of the property orientation.- Property description:
- Specifies the spinner's orientation.
-
orientationProperty
Specifies the spinner's orientation.- See Also:
-
setOrientation
Sets the value of the property orientation.- Property description:
- Specifies the spinner's orientation.
-
getPrevIconSupplier
Gets the value of the property prevIconSupplier.- Property description:
- The
Supplierused to build the icons which should triggerSpinnerModel.previous().Note that the
defaultIcons()add the needed event handlers to use theSpinnerModel, it is not handled automatically!
-
prevIconSupplierProperty
TheSupplierused to build the icons which should triggerSpinnerModel.previous().Note that the
defaultIcons()add the needed event handlers to use theSpinnerModel, it is not handled automatically! -
setPrevIconSupplier
Sets the value of the property prevIconSupplier.- Property description:
- The
Supplierused to build the icons which should triggerSpinnerModel.previous().Note that the
defaultIcons()add the needed event handlers to use theSpinnerModel, it is not handled automatically!
-
getNextIconSupplier
Gets the value of the property nextIconSupplier.- Property description:
- The
Supplierused to build the icons which should triggerSpinnerModel.next().Note that the
defaultIcons()add the needed event handlers to use theSpinnerModel, it is not handled automatically!
-
nextIconSupplierProperty
TheSupplierused to build the icons which should triggerSpinnerModel.next().Note that the
defaultIcons()add the needed event handlers to use theSpinnerModel, it is not handled automatically! -
setNextIconSupplier
Sets the value of the property nextIconSupplier.- Property description:
- The
Supplierused to build the icons which should triggerSpinnerModel.next().Note that the
defaultIcons()add the needed event handlers to use theSpinnerModel, it is not handled automatically!
-
getGraphicTextGap
public double getGraphicTextGap()Gets the value of the property graphicTextGap.- Property description:
- Specifies the space between the spinner's text and the two icons.
-
graphicTextGapProperty
Specifies the space between the spinner's text and the two icons.- See Also:
-
setGraphicTextGap
public void setGraphicTextGap(double graphicTextGap) Sets the value of the property graphicTextGap.- Property description:
- Specifies the space between the spinner's text and the two icons.
-