com.toedter.calendar

Class JCalendar

Implemented Interfaces:
PropertyChangeListener

public class JCalendar
extends JPanel
implements PropertyChangeListener

JCalendar is a bean for entering a date by choosing the year, month and day.
Version:
1.2
Author:
Kai Toedter

Field Summary

protected JDayChooser
dayChooser
the day chooser
protected Locale
locale
the locale
protected JMonthChooser
monthChooser
the month chooser
protected boolean
weekOfYearVisible
indicates if weeks of year shall be visible
protected JYearChooser
yearChooser
the year chhoser

Constructor Summary

JCalendar()
Default JCalendar constructor.
JCalendar(Date date)
JCalendar constructor which allows the initial date to be set.
JCalendar(Date date, Locale locale)
JCalendar constructor specifying both the initial date and locale.
JCalendar(Date date, Locale locale, boolean monthSpinner, boolean weekOfYearVisible)
JCalendar constructor with month spinner parameter.
JCalendar(Date date, boolean monthSpinner)
JCalendar constructor specifying both the initial date and the month spinner type.
JCalendar(Locale locale)
JCalendar constructor allowing the initial locale to be set.
JCalendar(Locale locale, boolean monthSpinner)
JCalendar constructor specifying both the locale and the month spinner.
JCalendar(boolean monthSpinner)
JCalendar constructor specifying the month spinner type.

Method Summary

Calendar
getCalendar()
Returns the calendar property.
Date
getDate()
Returns a Date object.
JDayChooser
getDayChooser()
Gets the dayChooser attribute of the JCalendar object
Color
getDecorationBackgroundColor()
Returns the color of the decoration (day names and weeks).
Locale
getLocale()
Returns the locale.
JMonthChooser
getMonthChooser()
Gets the monthChooser attribute of the JCalendar object
String
getName()
Returns "JCalendar".
Color
getSundayForeground()
Returns the Sunday foreground.
Color
getWeekdayForeground()
Returns the weekday foreground.
JYearChooser
getYearChooser()
Gets the yearChooser attribute of the JCalendar object
boolean
isDecorationBackgroundVisible()
Gets the visibility of the decoration background.
boolean
isDecorationBordersVisible()
Gets the visibility of the decoration border.
boolean
isEnabled()
Returns true, if enabled.
boolean
isWeekOfYearVisible()
Indicates if the weeks of year are visible..
static void
main(String[] s)
Creates a JFrame with a JCalendar inside and can be used for testing.
void
propertyChange(PropertyChangeEvent evt)
JCalendar is a PropertyChangeListener, for its day, month and year chooser.
void
setBackground(Color bg)
Sets the background color.
void
setCalendar(Calendar c)
Sets the calendar property.
void
setDate(Date date)
Sets the date.
void
setDecorationBackgroundColor(Color decorationBackgroundColor)
Sets the background of days and weeks of year buttons.
void
setDecorationBackgroundVisible(boolean decorationBackgroundVisible)
Sets the decoration background visible.
void
setDecorationBordersVisible(boolean decorationBordersVisible)
Sets the decoration borders visible.
void
setEnabled(boolean enabled)
Enable or disable the JCalendar.
void
setFont(Font font)
Sets the font property.
void
setForeground(Color fg)
Sets the foreground color.
void
setLocale(Locale l)
Sets the locale property.
void
setSundayForeground(Color sundayForeground)
Sets the Sunday foreground.
void
setWeekOfYearVisible(boolean weekOfYearVisible)
Sets the week of year visible.
void
setWeekdayForeground(Color weekdayForeground)
Sets the weekday foreground.

Field Details

dayChooser

protected JDayChooser dayChooser
the day chooser

locale

protected Locale locale
the locale

monthChooser

protected JMonthChooser monthChooser
the month chooser

weekOfYearVisible

protected boolean weekOfYearVisible
indicates if weeks of year shall be visible

yearChooser

protected JYearChooser yearChooser
the year chhoser

Constructor Details

JCalendar

public JCalendar()
Default JCalendar constructor.

JCalendar

public JCalendar(Date date)
JCalendar constructor which allows the initial date to be set.
Parameters:
date - the date

JCalendar

public JCalendar(Date date,
                 Locale locale)
JCalendar constructor specifying both the initial date and locale.
Parameters:
date - the date
locale - the new locale

JCalendar

public JCalendar(Date date,
                 Locale locale,
                 boolean monthSpinner,
                 boolean weekOfYearVisible)
JCalendar constructor with month spinner parameter.
Parameters:
date - the date
locale - the locale
monthSpinner - false, if no month spinner should be used
weekOfYearVisible - true, if weeks of year shall be visible

JCalendar

public JCalendar(Date date,
                 boolean monthSpinner)
JCalendar constructor specifying both the initial date and the month spinner type.
Parameters:
date - the date
monthSpinner - false, if no month spinner should be used

JCalendar

public JCalendar(Locale locale)
JCalendar constructor allowing the initial locale to be set.
Parameters:
locale - the new locale

JCalendar

public JCalendar(Locale locale,
                 boolean monthSpinner)
JCalendar constructor specifying both the locale and the month spinner.
Parameters:
locale - the locale
monthSpinner - false, if no month spinner should be used

JCalendar

public JCalendar(boolean monthSpinner)
JCalendar constructor specifying the month spinner type.
Parameters:
monthSpinner - false, if no month spinner should be used

Method Details

getCalendar

public Calendar getCalendar()
Returns the calendar property.
Returns:
the value of the calendar property.

getDate

public Date getDate()
Returns a Date object.
Returns:
a date object constructed from the calendar property.

getDayChooser

public JDayChooser getDayChooser()
Gets the dayChooser attribute of the JCalendar object
Returns:
the dayChooser value

getDecorationBackgroundColor

public Color getDecorationBackgroundColor()
Returns the color of the decoration (day names and weeks).
Returns:
the color of the decoration (day names and weeks).

getLocale

public Locale getLocale()
Returns the locale.
Returns:
the value of the locale property.

getMonthChooser

public JMonthChooser getMonthChooser()
Gets the monthChooser attribute of the JCalendar object
Returns:
the monthChooser value

getName

public String getName()
Returns "JCalendar".
Returns:
"JCalendar"

getSundayForeground

public Color getSundayForeground()
Returns the Sunday foreground.
Returns:
Color the Sunday foreground.

getWeekdayForeground

public Color getWeekdayForeground()
Returns the weekday foreground.
Returns:
Color the weekday foreground.

getYearChooser

public JYearChooser getYearChooser()
Gets the yearChooser attribute of the JCalendar object
Returns:
the yearChooser value

isDecorationBackgroundVisible

public boolean isDecorationBackgroundVisible()
Gets the visibility of the decoration background.
Returns:
true, if the decoration background is visible.

isDecorationBordersVisible

public boolean isDecorationBordersVisible()
Gets the visibility of the decoration border.
Returns:
true, if the decoration border is visible.

isEnabled

public boolean isEnabled()
Returns true, if enabled.
Returns:
true, if enabled.

isWeekOfYearVisible

public boolean isWeekOfYearVisible()
Indicates if the weeks of year are visible..
Returns:
boolean true, if weeks of year are visible

main

public static void main(String[] s)
Creates a JFrame with a JCalendar inside and can be used for testing.
Parameters:
s - The command line arguments

propertyChange

public void propertyChange(PropertyChangeEvent evt)
JCalendar is a PropertyChangeListener, for its day, month and year chooser.
Parameters:
evt - the property change event

setBackground

public void setBackground(Color bg)
Sets the background color.
Parameters:
bg - the new background

setCalendar

public void setCalendar(Calendar c)
Sets the calendar property. This is a bound property.
Parameters:
c - the new calendar

setDate

public void setDate(Date date)
Sets the date. Fires the property change "date".
Parameters:
date - the new date.

setDecorationBackgroundColor

public void setDecorationBackgroundColor(Color decorationBackgroundColor)
Sets the background of days and weeks of year buttons.
Parameters:
decorationBackgroundColor - the background color

setDecorationBackgroundVisible

public void setDecorationBackgroundVisible(boolean decorationBackgroundVisible)
Sets the decoration background visible.
Parameters:
decorationBackgroundVisible - true, if the decoration background should be visible.

setDecorationBordersVisible

public void setDecorationBordersVisible(boolean decorationBordersVisible)
Sets the decoration borders visible.
Parameters:
decorationBordersVisible - true, if the decoration borders should be visible.

setEnabled

public void setEnabled(boolean enabled)
Enable or disable the JCalendar.
Parameters:
enabled - the new enabled value

setFont

public void setFont(Font font)
Sets the font property.
Parameters:
font - the new font

setForeground

public void setForeground(Color fg)
Sets the foreground color.
Parameters:
fg - the new foreground

setLocale

public void setLocale(Locale l)
Sets the locale property. This is a bound property.
Parameters:
l - the new locale value

setSundayForeground

public void setSundayForeground(Color sundayForeground)
Sets the Sunday foreground.
Parameters:
sundayForeground - the sundayForeground to set

setWeekOfYearVisible

public void setWeekOfYearVisible(boolean weekOfYearVisible)
Sets the week of year visible.
Parameters:
weekOfYearVisible - true, if weeks of year shall be visible

setWeekdayForeground

public void setWeekdayForeground(Color weekdayForeground)
Sets the weekday foreground.
Parameters:
weekdayForeground - the weekdayForeground to set

Copyright B) 1999 - 2004 Kai Toedter.