Using JSlider to create a date picker?

I want to implement date picker using JSlider. The user should be able to use the slider to freely choose between two previously known dates. I saw such examples:

enter image description here

But I want to do the same using only one slider. The minimum distance between two points (tick) should be one day. Any tips on how to implement this?

+2
source share
3 answers

If you want to have a slider with min = 1.1.2012 and max = 10.1.2012, just create a slider with min = 0 and max = the number of days between them, then add the selected number in 1.1.2012.

, 10.1.2012 10 , min = 0 max = 9. .

+3

, JSlider, , Double/RangeSlider, , JSpinner SpinnerDateModel, - Java Calendar DatePicker

EDIT (@Robin)

enter image description here

+3

: JSlider, , , (, , setLabelTable)

,

  • . / , . , ,
  • It is difficult to get all dates as marks on the slider due to the limited width. This means that the user must interpolate / count to select the correct date.
  • If you adhere to the slider approach, at least consider adding a text box. Even an uneditable text field that displays the selected date will be a big improvement over the slider (see Clause 2).
+2
source

All Articles