c.fill = GridBagConstraints.HORIZONTAL;
// Build the two menus for selecting which calendar is displayed,
// plus the month/year label for each calendar
for (int i = 0; i < 2; i++) {
calMenu[i] = new Choice();
for (int j = 0; j < CALENDARS.length; j++) {
calMenu[i].addItem(CALENDARS[j].name);
}
calMenu[i].setBackground(DemoUtility.choiceColor);
calMenu[i].select(i);
calMenu[i].addItemListener(new CalMenuListener());
// Label for the current month name
monthLabel[i] = new ColoredLabel("", COLORS[i]);
monthLabel[i].setFont(DemoUtility.titleFont);
// And the default calendar to use for this slot
calendars[i] = CALENDARS[i].calendar;
add(topPanel, calMenu[i], g, c, 5, 0);
add(topPanel, monthLabel[i], g, c, GridBagConstraints.REMAINDER, 1);
}
// Now add the next/previous year/month buttons:
prevYear = new Button("<<");
prevYear.addActionListener(new AddAction(Calendar.YEAR, -1));
prevMonth = new Button("<");
prevMonth.addActionListener(new AddAction(Calendar.MONTH, -1));
gotoToday = new Button("Today");
gotoToday.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e) {
calendarPanel.setDate( new Date() );
updateMonthName();
}
} );
nextMonth = new Button(">");
nextMonth.addActionListener(new AddAction(Calendar.MONTH, 1));
nextYear = new Button(">>");
nextYear.addActionListener(new AddAction(Calendar.YEAR, 1));
c.fill = GridBagConstraints.NONE;
add(topPanel, prevYear, g, c, 1, 0);
add(topPanel, prevMonth, g, c, 1, 0);
add(topPanel, gotoToday, g, c, 1, 0);
add(topPanel, nextMonth, g, c, 1, 0);
add(topPanel, nextYear, g, c, 1, 0);
// Now add the menu for selecting the display language
Panel displayPanel = new Panel();
{
displayMenu = new Choice();
Locale defaultLocale = Locale.getDefault();
int bestMatch = -1, thisMatch = -1;
int selectMe = 0;
for (int i = 0; i < locales.length; i++) {