I have created an Integer Spinner with values
min (5), max (15) and initialValue (12)
and wrapAround (true)
.
Once the spinner reaches the max (15)
value during increment, instead of resetting the value to min (5)
as it says in the documentation, it is being reset to value 10 (max (15) - min (5))
public final void setWrapAround(boolean value)
Sets the value of the property wrapAround.
Property description:
The wrapAround property is used to specify whether the value factory should be circular. For example, should an integer-based value model increment from the maximum value back to the minimum value (and vice versa).
Note: Decrement works properly, once it reaches the min (5)
value, Spinner value automatically set to max (15)
public class IntSpinnerTest extends Application
{
@Override
public void start(Stage stage) throws Exception
{
var spinner = new Spinner<Integer>();
var factory = new SpinnerValueFactory.IntegerSpinnerValueFactory(5, 15, 12);
factory.setWrapAround(true);
spinner.setValueFactory(factory);
stage.setScene(new Scene(new BorderPane(spinner), 400, 200));
stage.setTitle("IntSpinnerTest");
stage.centerOnScreen();
stage.show();
}
public static void main(String[] args)
{
launch(args);
}
}