I want to disable just one arrow-button of the JavaFX Spinner component, so that they cannot assume illegal values:
I have 2 components spinnerMin
and spinnerMax
with [2-6] as range of values, as in this picture; the behaviour I want is that when they get to the same value (e.g. Min: 3, Max: 3) the up arrow of Min becomes disabled, aswell as the down arrow of Max.
Anyone knows if this is possible or how can I achieve that in the smoothest way possible?
Edit: Thank jewelsea for the suggestion. I've added a listener to the valueProperty and set the valueFactory to change the range and it works as expected, even though it still doesn't disable and "gray out" the arrow, which is the behaviour I would like to achieve (but at this point I'm wondering if it is even possible).
spinnerMin.valueProperty().addListener((changed, oldval, newval) -> {
spinnerMax.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(newval, 6, spinnerMax.getValue()));
});
spinnerMax.valueProperty().addListener((changed, oldval, newval) -> {
spinnerMin.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(2, newval, spinnerMin.getValue()));
});