Search code examples
javamaxjavafx-8minjdatechooser

How can i set the min and max value in a JDateChooser?


I saw there's another question like this but the answer isn't useful for me since I added the JDateChooser with the design option in NetBeans, so I don't know how to set the min and max date for the pick.


Solution

  • Assuming JDateChooser uses an extends of the SpinnerDateModel then you just need to get the model and set the start and end date.

    SpinnerDateModel model = (SpinnerDateModel) chooser.getModel();
    model.setStart(startDate)
    model.setEnd(endDate);