public void actionPerformed(ActionEvent arg0) {
            if (arg0.getSource().equals(nextMonthButton)) {
                GregorianCalendar cal = (GregorianCalendar)calendarModel.getCalendarClone();
                int day = cal.get(Calendar.DATE);
                cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, 1);
                if (day > cal.getActualMaximum(Calendar.DAY_OF_MONTH)) {
                    cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
                } else {
                    cal.set(Calendar.DATE, day);
                }
                calendarModel.setCalendar(cal.getTime());
            } else if (arg0.getSource().equals(previousMonthButton)) {
                GregorianCalendar cal = (GregorianCalendar)calendarModel.getCalendarClone();
                int day = cal.get(Calendar.DATE);
                cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) - 1, 1);
                if (day > cal.getActualMaximum(Calendar.DAY_OF_MONTH)) {
                    cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
                } else {
                    cal.set(Calendar.DATE, day);
                }
                calendarModel.setCalendar(cal.getTime());
            } else {
                for (int month = 0; month < monthPopupMenuItems.length; month++) {
                    if (arg0.getSource().equals(monthPopupMenuItems[month])) {
                        GregorianCalendar cal = (GregorianCalendar)calendarModel.getCalendarClone();
                        int day = cal.get(Calendar.DATE);
                        cal.set(cal.get(Calendar.YEAR), month, 1);
                        if (day > cal.getActualMaximum(Calendar.DAY_OF_MONTH)) {
                            cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
                        } else {
                            cal.set(Calendar.DATE, day);
                        }
                        calendarModel.setCalendar(cal.getTime());
                    }
                }
            }
        }