dividerColor = theme.getColor(9);
selectionBevelColor = TerraTheme.brighten(selectionBackgroundColor);
// Create the table pane
calendarTablePane = new TablePane();
for (int i = 0; i < 7; i++) {
calendarTablePane.getColumns().add(new TablePane.Column(1, true));
}
// Month spinner
monthSpinner = new Spinner();
monthSpinner.setSpinnerData(new NumericSpinnerData(0, 11));
monthSpinner.setItemRenderer(new MonthSpinnerItemRenderer());
monthSpinner.setCircular(true);
monthSpinner.getStyles().put("sizeToContent", true);
monthSpinner.getSpinnerSelectionListeners().add(new SpinnerSelectionListener() {
@Override
public void selectedIndexChanged(Spinner spinner, int previousSelectedIndex) {
Calendar calendar = (Calendar)getComponent();
calendar.setMonth((Integer)spinner.getSelectedItem());
}
});
// Year spinner
yearSpinner = new Spinner();
yearSpinner.setSpinnerData(new NumericSpinnerData(0, Short.MAX_VALUE));
yearSpinner.getSpinnerSelectionListeners().add(new SpinnerSelectionListener() {
@Override
public void selectedIndexChanged(Spinner spinner, int previousSelectedIndex) {
Calendar calendar = (Calendar)getComponent();
calendar.setYear((Integer)spinner.getSelectedItem());
}
});
// Attach a listener to consume mouse clicks
ComponentMouseButtonListener spinnerMouseButtonListener = new ComponentMouseButtonListener.Adapter() {
@Override
public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
return true;
}
};
monthSpinner.getComponentMouseButtonListeners().add(spinnerMouseButtonListener);
yearSpinner.getComponentMouseButtonListeners().add(spinnerMouseButtonListener);
// Add the month/year table pane
TablePane monthYearTablePane = new TablePane();
monthYearTablePane.getStyles().put("padding", 3);
monthYearTablePane.getStyles().put("horizontalSpacing", 4);
monthYearTablePane.getColumns().add(new TablePane.Column(1, true));
monthYearTablePane.getColumns().add(new TablePane.Column(-1));
TablePane.Row monthYearRow = new TablePane.Row(-1);
monthYearTablePane.getRows().add(monthYearRow);
monthYearRow.add(monthSpinner);
monthYearRow.add(yearSpinner);
TablePane.Row calendarRow = new TablePane.Row();
calendarRow.add(monthYearTablePane);