javajcalendar

JCalendar get the current date clicked


So I have this

    @Override
        public void propertyChange(PropertyChangeEvent evt) {
            Date current = new Date(System.currentTimeMillis());

            if (calendar.getDate().after(current) || (calendar.getDate().getDate() == current.getDate()
                    && calendar.getDate().getMonth() == current.getMonth()
                    && calendar.getDate().getYear() == current.getYear())) {

                int month = calendar.getMonthChooser().getMonth() + 1;
                int day = (int) evt.getNewValue();

                String date = day + "/" + month;
                txtNothing.setText("Event:" + date);
                dispose();
            }
        }
    });

I know it can be better but this works for listening for a change in dates..

What can I use to get the current date selected when it is pressed again? currently that date is still highlighted but the propertychange event wont trigger when clicked the same date.


Solution

  • found a way to trigger it by using this

    calendar.getDayChooser().setAlwaysFireDayProperty(true);