I'm wondering how to set the value of a JavaFX Spinner, as I haven't been able to figure it out.
I know with Swing you can just use spinner#setValue but it seems to be different with JavaFX.
@FXML
private Spinner<Integer> spinner;
spinner.getValueFactory().setValue(...);
Just in addition to James_D's answer, an extract of the JavaDoc of the value
attribute of the Spinner
class:
The value property on Spinner is a read-only property, as it is bound to the SpinnerValueFactory value property. Should the value factory change, this value property will be unbound from the old value factory and bound to the new one. If developers wish to modify the value property, they may do so with code in the ollowing form:
Object newValue = ...; spinner.getValueFactory().setValue(newValue);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With