forked from j62/ctbrec
1
0
Fork 0

Fix IndexOutOfBoundsException in RangeSLiderBehavior

This commit is contained in:
0xboobface 2020-06-14 11:21:33 +02:00
parent 56a41df4e7
commit fa37266485
1 changed files with 1 additions and 0 deletions

View File

@ -47,6 +47,7 @@ public class RangeSliderBehavior<T extends Number> extends BehaviorBase<RangeSli
List<T> ticks = rangeSlider.getRange().getTicks(); List<T> ticks = rangeSlider.getRange().getTicks();
double percentPerTick = 1d / (ticks.size() - 1); double percentPerTick = 1d / (ticks.size() - 1);
int index = (int) Math.round(position / percentPerTick); int index = (int) Math.round(position / percentPerTick);
index = Math.min(ticks.size() - 1, Math.max(0, index));
return ticks.get(index); return ticks.get(index);
} }
} }