public void selectionChanged(Group group, Button previousSelection) {
Calendar calendar = (Calendar)getComponent();
Button selection = group.getSelection();
if (selection == null) {
CalendarDate selectedDate = calendar.getSelectedDate();
// If no date was selected, or the selection changed as a
// result of the user toggling the date button (as opposed
// to changing the month or year), clear the selection
if (selectedDate == null
|| (selectedDate.getYear() == yearSpinner.getSelectedIndex()
&& selectedDate.getMonth() == monthSpinner.getSelectedIndex())) {
calendar.setSelectedDate((CalendarDate)null);
}
} else {
calendar.setSelectedDate((CalendarDate)selection.getButtonData());
}