I want time like 02:25:12AM hour,min,sec in one spinner. How can I do that? I have done only for one value like
<Spinner fx:id="spinner" layoutX="350.0" layoutY="10.0" initialValue="60"
max="120" prefHeight="25.0" prefWidth="60.0" />
It shows error like
jaavaFx.scene.control.Spinner does not support min/max/intial propery
But it works fine. Now I want to do it for 3 values.
As @UlukBiy says in the comments, you probably want to use three spinners here. You probably also want to implement "wrap around", so that if you increment the number of seconds past 59, it resets to 0 and the minutes increment, etc.
Also, to set the min and max, you set them on the
SpinnerValueFactory
, not on theSpinner
itself. See the Javadocs forSpinner
,SpinnerValueFactory
, andSpinnerValueFactory.IntegerSpinnerValueFactory
.Here is a complete example (in FXML):
TimeSpinner.fxml:
TimeSpinnerController:
Test code: