JCalendar getting date

olyanren picture olyanren · Apr 23, 2011 · Viewed 21.5k times · Source

In my project I am using com.toedter.calendar.JCalendar class. But I do not know how can I get date when date is chosen.

JDateChooser and JXDatePicker met my need. There is a code that provides date when a date is chosen from JDateChooser.

JDateChooser picker=new JDateChooser();

picker.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            setDate(picker.getDate());
        }
 }); 

Answer

trashgod picture trashgod · Apr 23, 2011

You definitely want addPropertyChangeListener(), but you need to check getNewValue(). There's a good example here.