I am working on a project that uses an interactive calendar. I intended for the user to click a date on the JCalendar, and if an event took place on that day then a pop-up would display, telling the user what event took place. If there was no event on that day, a pop-up would display telling the user that there was no event that day. How would I register this interaction with the JCalendar, and turn this interaction into a dialog box on the screen?
Asked
Active
Viewed 156 times
1 Answers
1
Add a PropertyChangeListener
to your JCalendar
for "calendar"
. Check the resulting Date
against your event and bring up a JOptionPane
to show the result.
JCalendar jc = new JCalendar(c);
jc.addPropertyChangeListener("calendar", new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
System.out.println(e.getPropertyName() + ": "
+ ((GregorianCalendar)e.getNewValue()).getTime());
}
});

Catalina Island
- 7,027
- 2
- 23
- 42