|
JDatePicker v4.3 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.standbysoft.component.date.swing.DefaultMonthModel
A default implementation for a MonthModel. It adds a few methods
that are not specified in the interface in order to make the specification
of month names easier.
The month names are determined using a locale
and a format (short or
long).
One can also specify custom month names by overriding the
getMonthNames() method.
| Field Summary | |
static int |
MONTH_NAMES_LONG
Type value indicating that the months' names are long. |
static int |
MONTH_NAMES_SHORT
Type value indicating that the months' names are short. |
| Constructor Summary | |
DefaultMonthModel()
Creates a default month model that uses the default locale. |
|
| Method Summary | |
void |
addMonthModelListener(MonthModelListener listener)
Adds an object that listens to changes in this model. |
protected void |
fireMonthChanged(MonthModelEvent evt)
DefaultMonthModel subclasses must call this method when the month represented by the model changes. |
protected void |
fireMonthNamesChanged(MonthModelEvent evt)
DefaultMonthModel subclasses must call this method when the format for the month names changes. |
protected void |
fireTodayChanged(MonthModelEvent evt)
DefaultMonthModel subclasses must call this method when the reference today date changes. |
java.util.EventListener[] |
getListeners(java.lang.Class listenerType)
|
java.util.Locale |
getLocale()
Returns the locale used to detrmine the names of the months. |
int |
getMonth()
Returns the month represented by this model. |
java.lang.String[] |
getMonthNames()
Returns the names of the months that are determined using the current locale and a format. |
int |
getMonthNamesFormat()
Returns the current format used to represent the month names. |
java.util.TimeZone |
getTimeZone()
Returns the time zone used to determine whether a date belongs to the month represented by this model or not. |
java.util.Date |
getToday()
Returns the today reference date. |
int |
getYear()
Returns the year to which the represented month belongs. |
boolean |
isToday(java.util.Date date)
Determines whether a specified date matches the today date (the year, month and date fields in fact). |
boolean |
isTrailingNext(java.util.Date date)
Determines if a specified date belongs to a following month. |
boolean |
isTrailingPrevious(java.util.Date date)
Determines if a specified date belongs to a previous month. |
void |
removeMonthModelListener(MonthModelListener listener)
Removes a specified listener from the list of registered listeners. |
void |
setLocale(java.util.Locale locale)
Specifies a new locale to change the month names. |
void |
setMonth(int amonth)
Specifies a new month to be represented by this model. |
void |
setMonth(int month,
int year)
Specifies a new month to be represented by this model. |
void |
setMonthNamesFormat(int format)
Changes the format for the month names. |
void |
setTimeZone(java.util.TimeZone timezone)
Specifies the time zone used to determine whether a date belongs to the month represented by this model or not. |
void |
setToday(java.util.Date date)
Specifies a new date to be considered the today date. |
void |
setYear(int ayear)
Specifies a new year to which the represented month belongs. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int MONTH_NAMES_SHORT
public static final int MONTH_NAMES_LONG
| Constructor Detail |
public DefaultMonthModel()
MONTH_NAMES_SHORT format and the current month
is selected.
| Method Detail |
public java.lang.String[] getMonthNames()
Returns the names of the months that are determined using the current locale and a format. This approach should solve most cases and for special needs one can just override it and provide some custom names.
getMonthNames in interface MonthModelsetLocale(Locale),
setMonthNamesFormat(int)public void setLocale(java.util.Locale locale)
locale - locale that determines the month names.getMonthNames(),
setMonthNamesFormat(int)public java.util.Locale getLocale()
setLocale(Locale)public void setMonthNamesFormat(int format)
format - format used to represent the names. Allowed values are
MONTH_NAMES_SHORT and MONTH_NAMES_LONGgetMonthNames(),
setLocale(Locale)public int getMonthNamesFormat()
MONTH_NAMES_SHORT or MONTH_NAMES_LONG.setMonthNamesFormat(int)public void setMonth(int amonth)
MonthModel
setMonth in interface MonthModelamonth - new month to be used by this model. The values are
Calendar constants like Calendar.JANUARY.MonthModel.getYear(),
MonthModel.setMonth(int, int)public void setYear(int ayear)
MonthModel
setYear in interface MonthModelayear - year to which the represented month belongs.MonthModel.setMonth(int, int)
public void setMonth(int month,
int year)
MonthModel
setMonth in interface MonthModelmonth - new month to be used by this model. The values are
Calendar constants like Calendar.JANUARYyear - year to which the represented month belongsMonthModel.setMonth(int),
MonthModel.setYear(int)public int getMonth()
MonthModel
getMonth in interface MonthModelCalendar constant
like Calendar.JANUARY.MonthModel.getYear()public int getYear()
MonthModel
getYear in interface MonthModelMonthModel.getMonth()public boolean isTrailingPrevious(java.util.Date date)
MonthModel
isTrailingPrevious in interface MonthModeldate - date that is tested if it is previous to this month
true if the date is before the first date of this
month; false otherwise.public boolean isTrailingNext(java.util.Date date)
MonthModel
isTrailingNext in interface MonthModeldate - date that is tested if it is after this month
true if the date is after the last date of this
month; false otherwise.public boolean isToday(java.util.Date date)
MonthModel
isToday in interface MonthModeldate - date that is tested
true if the date matches the today date;
false otherwise.public void setToday(java.util.Date date)
MonthModelSpecifies a new date to be considered the today date. This date is
particularly important for the date renderer and the
JMonthView component which uses a label to display the today
date.
Although setting the today date might seem a little weird, it makes
sense if the application runs for a few days. Specifying the today date
might be done automatically by a timer thread. In fact, JMonth
uses such a thread to do it automatically.
When the today date changes, all interested listeners are notified via
a MonthModelListener.todayChanged(MonthModelEvent) event.
setToday in interface MonthModeldate - new date that will be the today referenceMonthModel.isToday(Date)public java.util.Date getToday()
MonthModel
getToday in interface MonthModelMonthModel.setToday(Date)public void addMonthModelListener(MonthModelListener listener)
MonthModel
addMonthModelListener in interface MonthModellistener - the listener object that is informed about changes in this modelpublic void removeMonthModelListener(MonthModelListener listener)
MonthModel
removeMonthModelListener in interface MonthModellistener - the listener to be removedpublic java.util.EventListener[] getListeners(java.lang.Class listenerType)
protected void fireMonthNamesChanged(MonthModelEvent evt)
protected void fireMonthChanged(MonthModelEvent evt)
protected void fireTodayChanged(MonthModelEvent evt)
public void setTimeZone(java.util.TimeZone timezone)
MonthModel
setTimeZone in interface MonthModeltimezone - new time zonepublic java.util.TimeZone getTimeZone()
MonthModel
getTimeZone in interface MonthModelMonthModel.setTimeZone(TimeZone)
|
JDatePicker v4.3 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Visit www.jdatepicker.com for further information or send us your suggestions.
Copyright © 2003-2007 Stand By Soft Ltd. All Rights Reserved.