updateSelection(calendar.getSelectedDate());
}
private void updateSelection(CalendarDate selectedDate) {
Calendar calendar = (Calendar)getComponent();
Button selection = dateButtonGroup.getSelection();
if (selectedDate == null) {
if (selection != null) {
selection.setSelected(false);
}
} else {
int year = selectedDate.getYear();
int month = selectedDate.getMonth();
if (year == calendar.getYear()
&& month == calendar.getMonth()) {
int day = selectedDate.getDay();
// Update the button group
int cellIndex = getCellIndex(year, month, day, calendar.getLocale());
int rowIndex = cellIndex / 7;
int columnIndex = cellIndex % 7;
TablePane.Row row = tablePane.getRows().get(rowIndex + 2);
DateButton dateButton = (DateButton)row.get(columnIndex);
dateButton.setSelected(true);
} else {
if (selection != null) {
selection.setSelected(false);
}
}
}
}