Reputation: 1250
Hey guys I just want to know if how can I disable future dates in JXDatepicker. By future dates I mean the days after the current system date. I really need it for a system I'm developing.
Any help will be appreciated. Thank you.
Upvotes: 0
Views: 2396
Reputation: 21
Callback<DatePicker, DateCell> callB = new Callback<DatePicker, DateCell>() {
@Override
public DateCell call(final DatePicker param) {
return new DateCell() {
@Override
public void updateItem(LocalDate item, boolean empty) {
super.updateItem(item, empty); //To change body of generated methods, choose Tools | Templates.
LocalDate today = LocalDate.now();
setDisable(empty || item.compareTo(today) > 0);
}
};
}
};
selectedDate.setDayCellFactory(callB);
disable future date in date picker
Upvotes: 0
Reputation: 8806
See answer https://stackoverflow.com/a/13226347/274350 - picker.getMonthView().setUpperBound(new Date().getTime());
should do what you want.
Upvotes: 1