Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+17 votes

Our team is using sliders to determine the size of the map prior to editing. Our sliders give a range from 10 to 30 on both width and length. However, in certain circumstances, we want to have users to pick from at least 20 by 20. Right now, I have the size controller window to make a warning alert if the size was smaller than 20 by 20. But I want to make sliders to change so that from 20 to 30 is only given without making another fxml. Is there a way to make sliders look from 20 to 30 instead of original(10 to 30) without creating a new fxml when maze and random were selected?

asked in CSC305 Fall 2022 by (8 points)

2 Answers

+10 votes

Sliders have a setMin method that you could call, taking a new (double) minimum value for the slider. Try calling that somewhere in your controller.

answered by (8 points)

I tried setMin and setMax method but in UI it won't change the appearance of sliders.


That seems odd -- I think setMin and setMax ought to do the trick. Where/when are you calling setMin and setMax on the slider in your code? In the initialize method for that controller? (And did you remember to put the @FXML annotation above the initialize method?)

+6 votes

Did you try to edit the slider in the scene builder by right clicking on the slider and then selecting ‘set slider min and max’? It will look like this: min: (textbox)

answered by (8 points)