How to convert Integer
To ObservableValue<Integer>
in javafx 2.0 and later ?
We use a ReadOnlyObjectWrapper<>(*integer value*);
and store the value in a ObservableValue<Integer>
reference.
ObservableValue<Integer> obsInt = new ReadOnlyObjectWrapper<>(intValue);
Update
Starting JavaFX 8, you can also do the following :
ObservableValue<Integer> obsInt = new SimpleIntegerProperty(intValue).asObject();
Another way.
new SimpleIntegerProperty(integer_value).asObject()
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