i\'m trying to limit user to select only the date after today, or select date after another Date
I see on JCalendar API
something that could help me but i didn\
I do not think there is a straight forward way on the component to do this.
One way, that I know of is to use the setSelectableDateRange(Date from,Date to)
- When you set the from date to current date, all previous day cells, year/month drop downs becomes disabled.
Example:
JCalendar calendar = new JCalendar();
calendar.setSelectableDateRange(new Date(),new SimpleDateFormat("MM-DD-YYYY").parse("05-05-2015"));
PropertyChangeListener calendarChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
Date selectedDate = ((JCalendar)evt.getSource()).getDate();
}
};
calendar.addPropertyChangeListener("calendar",calendarChangeListener);
This will disable selection of any date before current date and after 05/05/2015
Note that this API is not documented in their javadoc. But still this is a public setter that works as expected.
EDIT since you want to know how JDateChooser
can be used in similar context
JDateChooser chooser = new JDateChooser();
chooser.getJCalendar().setSelectableDateRange(new Date(),new SimpleDateFormat("MM-DD-YYYY").parse("05-05-2015"));
chooser.getJCalendar().addPropertyChangeListener("calendar",...);