2

I want to have a range sldier that shows for example the values 0 to 24, but of which the lower thumb is bound to a minimum value depending on the hour of the day (such that it cannot be set in the past).

I looked through the RangeSlider docs and the Slider docs, but cannot seem to find a property that suits my needs. Any ideas in how I can set the min value of a range slider other than the setMin() method? When this method is used, it completely discards the values in the slider lower than the set minimum which I want to avoid.

Any help is deeply appreciated.

k88
  • 1,858
  • 2
  • 12
  • 33

1 Answers1

1

let your range be called in the FXML file like this:

 <RangeSlider fx:id="rangeSlider" blockIncrement="20.0" 
       highValue="50.0" lowValue="10.0" min="0.0" max="59.0"
       minorTickCount="50" prefHeight="38.0" prefWidth="821.0" 
       showTickLabels="true" showTickMarks="true" 
       snapToTicks="true" style="-fx-background-color: transparent;" />

and it the controller inject this rangeSlider as well

@FXML
private RangeSlider rangeSlider;

then use the methods adjustLowValue and adjustHighValue to set the values you want

@Override
public void initialize(URL url, ResourceBundle rb) {

    ...
    rangeSlider.adjustLowValue(10);
    rangeSlider.adjustHighValue(50);
}

hoping this help some way

azdoud
  • 1,229
  • 9
  • 17