Reputation: 790
I have this JavaFX Slider:
As you can see, the min value is 1 and the major tick unit is 5.
But what I'd like to achieve is this:
or at least this:
So basically, I want to move the whole scale to the left by 1 tick. But how?
(I also saw this post, but isn't there a quicker and easier way? Or do I really have to define my own Slider for this little task?)
Okay, I tried to make my own slider then. But I'm really lost.
This is what I want to do logically; but I don't know how to do it practially:
public class ImprovedTicksSlider extends Slider {
public void setTickMarks(int majorTickUnit, int minorTickCount) {
// 1.)
// set the first major tick mark at
// getMin() + (majorTickUnit - getMin() % majorTickUnit)
// 2.)
// set minor tick count in the very first block to:
// majorTickUnit - (getMin() % majorTickUnit)
// 3.)
// set all other major tick marks at positions where
// (x % majorTickUnit == 0)
// 4.)
// set all other blocks of minor ticks to (minorTickCount)
// like it would usually be the case in a standard Slider
// ...but how?!
}
}
Upvotes: 0
Views: 1755
Reputation: 21
I think you pretty much got it. You'll have to use a custom Slider since this basic slider only supports regular tick intervals.
The custom slider isn't really that big and you can import it in FXML so it's not a big problem.
Upvotes: 0