RFR: 8242553: IntegerSpinner and DoubleSpinner do not wrap around values correctly in some cases

Kevin Rushforth kcr at openjdk.org
Wed Mar 27 19:08:27 UTC 2024


On Wed, 27 Mar 2024 18:30:24 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

> the end result of stepping once by `amountToStepBy` must be equivalent of incrementing by one a total of `amountToStepBy` times, wouldn't you agree?

Yes, this is the expectaion.

> so the formula for positive `amountToStepBy` values should look like
> 
> `((val + amountToStepBy) % (max - min)) + min`
> 
> or something along these lines.

Not quite. Because the range is inclusive on both ends, the number of discrete positions is `max - min + 1`. In your above example , where `min=0` and `max=100`, there are 101 discrete positions. A single step by 101 or 101 steps by 1 will both bring you back to the same position you started from.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1431#issuecomment-2023752621


More information about the openjfx-dev mailing list