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

drmarmac duke at openjdk.org
Sat Mar 30 17:25:36 UTC 2024


On Sun, 24 Mar 2024 15:11:16 GMT, drmarmac <duke at openjdk.org> wrote:

> This PR should fix the issue and cover all relevant cases with new tests.
> 
> Note: This involves a small behavior change, as can be seen in dblSpinner_testWrapAround_decrement_twoSteps() in SpinnerTest.java:749. With this change the wraparound behavior is similar to that of the IntegerSpinner.

I see these possible definitions for the double spinner behavior with wraparound:
1) Current PR: Wraparound uses amountToStepBy amount, formula: MOD (max - min + amountToStepBy)
2) Make it behave like the integer spinner, meaning the wraparound is always a step size of 1, formula: MOD (max - min + 1)
3) Calculate MOD (max - min), which would make the upper limit non-inclusive (i.e. it will never be reached).
4) Calculate MOD (max - min) only when > max, i.e. allow the maximum, but calculate like it's the same as the minimum, meaning stepping directly from max to min and vice versa is usually not possible. Also, both max and min values will only be reachable from one direction.
Looking at this again, maybe 4) is actually preferable?

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

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


More information about the openjfx-dev mailing list