/**
   * Sets the background color.
   *
   * @param bg the new background
   */
  public void setBackground(Color bg) {
    super.setBackground(bg);

    if (dayChooser != null) {
      dayChooser.setBackground(bg);
    }
  }
  /**
   * Sets the foreground color.
   *
   * @param fg the new foreground
   */
  public void setForeground(Color fg) {
    super.setForeground(fg);

    if (dayChooser != null) {
      dayChooser.setForeground(fg);
      monthChooser.setForeground(fg);
      yearChooser.setForeground(fg);
    }
  }
  /**
   * Sets the font property.
   *
   * @param font the new font
   */
  public void setFont(Font font) {
    super.setFont(font);

    if (dayChooser != null) {
      dayChooser.setFont(font);
      monthChooser.setFont(font);
      yearChooser.setFont(font);
    }
  }
  /**
   * Enable or disable the JCalendar.
   *
   * @param enabled the new enabled value
   */
  public void setEnabled(boolean enabled) {
    super.setEnabled(enabled);

    if (dayChooser != null) {
      dayChooser.setEnabled(enabled);
      monthChooser.setEnabled(enabled);
      yearChooser.setEnabled(enabled);
    }
  }
  /**
   * Sets the date. Fires the property change "date".
   *
   * @param date the new date.
   */
  public void setDate(Date date) {
    Date oldDate = calendar.getTime();
    calendar.setTime(date);

    yearChooser.setYear(calendar.get(Calendar.YEAR));
    monthChooser.setMonth(calendar.get(Calendar.MONTH));
    dayChooser.setDay(calendar.get(Calendar.DATE));

    firePropertyChange("date", oldDate, date);
  }
 /**
  * Sets the locale property. This is a bound property.
  *
  * @param l the new locale value
  * @see #getLocale
  */
 public void setLocale(Locale l) {
   if (!initialized) {
     super.setLocale(l);
   } else {
     Locale oldLocale = locale;
     locale = l;
     dayChooser.setLocale(locale);
     monthChooser.setLocale(locale);
     firePropertyChange("locale", oldLocale, locale);
   }
 }
  /**
   * Sets the calendar attribute of the JCalendar object
   *
   * @param c the new calendar value
   * @param update the new calendar value
   */
  private void setCalendar(Calendar c, boolean update) {
    Calendar oldCalendar = calendar;
    calendar = c;

    if (update) {
      // Thanks to Jeff Ulmer for correcting a bug in the sequence :)
      yearChooser.setYear(c.get(Calendar.YEAR));
      monthChooser.setMonth(c.get(Calendar.MONTH));
      dayChooser.setDay(c.get(Calendar.DATE));
    }

    firePropertyChange("calendar", oldCalendar, calendar);
  }
  /**
   * JCalendar constructor with month spinner parameter.
   *
   * @param date the date
   * @param locale the locale
   * @param monthSpinner false, if no month spinner should be used
   * @param weekOfYearVisible true, if weeks of year shall be visible
   */
  public JCalendar(Date date, Locale locale, boolean monthSpinner, boolean weekOfYearVisible) {
    // needed for setFont() etc.
    dayChooser = null;
    monthChooser = null;
    yearChooser = null;
    this.weekOfYearVisible = weekOfYearVisible;

    this.locale = locale;

    if (locale == null) {
      this.locale = Locale.getDefault();
    }

    Locale.setDefault(new Locale("ru", "RU"));
    calendar = Calendar.getInstance();

    setLayout(new BorderLayout());

    monthYearPanel = new JPanel();
    monthYearPanel.setLayout(new BorderLayout());

    monthChooser = new JMonthChooser(monthSpinner);
    yearChooser = new JYearChooser();
    monthChooser.setYearChooser(yearChooser);
    monthYearPanel.add(monthChooser, BorderLayout.WEST);
    monthYearPanel.add(yearChooser, BorderLayout.CENTER);
    monthYearPanel.setBorder(BorderFactory.createEmptyBorder());

    dayChooser = new JDayChooser(weekOfYearVisible);
    dayChooser.addPropertyChangeListener(this);
    monthChooser.setDayChooser(dayChooser);
    monthChooser.addPropertyChangeListener(this);
    yearChooser.setDayChooser(dayChooser);
    yearChooser.addPropertyChangeListener(this);
    add(monthYearPanel, BorderLayout.NORTH);
    add(dayChooser, BorderLayout.CENTER);

    // Set the initialized flag before setting the calendar. This will
    // cause the other components to be updated properly.
    if (date != null) {
      calendar.setTime(date);
    }

    initialized = true;
    setCalendar(calendar);
  }
 /**
  * Gets the visibility of the decoration background.
  *
  * @return true, if the decoration background is visible.
  */
 public boolean isDecorationBackgroundVisible() {
   return dayChooser.isDecorationBackgroundVisible();
 }
 /**
  * Sets the Sunday foreground.
  *
  * @param sundayForeground the sundayForeground to set
  */
 public void setSundayForeground(Color sundayForeground) {
   dayChooser.setSundayForeground(sundayForeground);
 }
 /**
  * Sets the weekday foreground.
  *
  * @param weekdayForeground the weekdayForeground to set
  */
 public void setWeekdayForeground(Color weekdayForeground) {
   dayChooser.setWeekdayForeground(weekdayForeground);
 }
 /**
  * Sets the background of days and weeks of year buttons.
  *
  * @param decorationBackgroundColor the background color
  */
 public void setDecorationBackgroundColor(Color decorationBackgroundColor) {
   dayChooser.setDecorationBackgroundColor(decorationBackgroundColor);
 }
 /**
  * Returns the weekday foreground.
  *
  * @return Color the weekday foreground.
  */
 public Color getWeekdayForeground() {
   return dayChooser.getWeekdayForeground();
 }
 /**
  * Returns the color of the decoration (day names and weeks).
  *
  * @return the color of the decoration (day names and weeks).
  */
 public Color getDecorationBackgroundColor() {
   return dayChooser.getDecorationBackgroundColor();
 }
 /**
  * Sets the decoration borders visible.
  *
  * @param decorationBordersVisible true, if the decoration borders should be visible.
  */
 public void setDecorationBordersVisible(boolean decorationBordersVisible) {
   dayChooser.setDecorationBordersVisible(decorationBordersVisible);
   setLocale(locale); // hack for doing complete new layout :)
 }
 /**
  * Gets the visibility of the decoration border.
  *
  * @return true, if the decoration border is visible.
  */
 public boolean isDecorationBordersVisible() {
   return dayChooser.isDecorationBordersVisible();
 }
 /**
  * Indicates if the weeks of year are visible..
  *
  * @return boolean true, if weeks of year are visible
  */
 public boolean isWeekOfYearVisible() {
   return dayChooser.isWeekOfYearVisible();
 }
 /**
  * Sets the week of year visible.
  *
  * @param weekOfYearVisible true, if weeks of year shall be visible
  */
 public void setWeekOfYearVisible(boolean weekOfYearVisible) {
   dayChooser.setWeekOfYearVisible(weekOfYearVisible);
   setLocale(locale); // hack for doing complete new layout :)
 }