JDatePicker v4.3

com.standbysoft.component.date.swing
Interface MonthModel

All Known Implementing Classes:
DefaultMonthModel

public interface MonthModel

A month model is a helper interface that lets you control different settings for a JMonth component. The idea of this interface is to have a single point of control for various month aspects. It can:

See Also:
WeekModel, JMonth

Method Summary
 void addMonthModelListener(MonthModelListener listener)
          Adds an object that listens to changes in this model.
 int getMonth()
          Returns the month represented by this model.
 java.lang.String[] getMonthNames()
          Determines the names of the months.
 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 setMonth(int month)
          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 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 year)
          Specifies a new year to which the represented month belongs.
 

Method Detail

addMonthModelListener

public void addMonthModelListener(MonthModelListener listener)
Adds an object that listens to changes in this model.

Parameters:
listener - the listener object that is informed about changes in this model

removeMonthModelListener

public void removeMonthModelListener(MonthModelListener listener)
Removes a specified listener from the list of registered listeners.

Parameters:
listener - the listener to be removed

getMonthNames

public java.lang.String[] getMonthNames()
Determines the names of the months. To get the name for a certain month access the array with the Calendar id of the respective month. For instance to get the name for January, you should do something like:
 String[] names = model.getMonthNames();
 String jan = names[Calendar.JANUARY];
 

Returns:
names of the months.

getMonth

public int getMonth()
Returns the month represented by this model.

Returns:
month represented by this model as a Calendar constant like Calendar.JANUARY.
See Also:
getYear()

getYear

public int getYear()
Returns the year to which the represented month belongs.

Returns:
the year to which the represented month belongs.
See Also:
getMonth()

setMonth

public void setMonth(int month)
Specifies a new month to be represented by this model. The month will be the month of the current year. Only months that belong to the allowed dates interval are valid.

Parameters:
month - new month to be used by this model. The values are Calendar constants like Calendar.JANUARY.
See Also:
getYear(), setMonth(int, int)

setYear

public void setYear(int year)
Specifies a new year to which the represented month belongs. Only years that belong to the allowed dates interval are valid.

Parameters:
year - year to which the represented month belongs.
See Also:
setMonth(int, int)

setMonth

public void setMonth(int month,
                     int year)
Specifies a new month to be represented by this model. The month will be the month of the current year. Only months that belong to the allowed dates interval are valid.

Parameters:
month - new month to be used by this model. The values are Calendar constants like Calendar.JANUARY
year - year to which the represented month belongs
See Also:
setMonth(int), setYear(int)

isTrailingNext

public boolean isTrailingNext(java.util.Date date)
Determines if a specified date belongs to a following month. For instance if the current month is January 2000, then February 11 2000 is a next trailing date.

Parameters:
date - date that is tested if it is after this month
Returns:
true if the date is after the last date of this month; false otherwise.

isTrailingPrevious

public boolean isTrailingPrevious(java.util.Date date)
Determines if a specified date belongs to a previous month. For instance if the current month is January 2000, then December 23 1999 is a previous trailing date.

Parameters:
date - date that is tested if it is previous to this month
Returns:
true if the date is before the first date of this month; false otherwise.

isToday

public boolean isToday(java.util.Date date)
Determines whether a specified date matches the today date (the year, month and date fields in fact).

Parameters:
date - date that is tested
Returns:
true if the date matches the today date; false otherwise.

setToday

public void setToday(java.util.Date date)

Specifies 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.

Parameters:
date - new date that will be the today reference
See Also:
isToday(Date)

getToday

public java.util.Date getToday()
Returns the today reference date.

Returns:
today reference date.
See Also:
setToday(Date)

setTimeZone

public 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. This property is used internally by the date components to synchronize their time zone with this model so that it can determine if a date is before or after this month or if it is the today date.

Parameters:
timezone - new time zone

getTimeZone

public java.util.TimeZone getTimeZone()
Returns the time zone used to determine whether a date belongs to the month represented by this model or not.

Returns:
time zone used to determine whether a date belongs to the month represented by this model or not
See Also:
setTimeZone(TimeZone)

JDatePicker v4.3

Visit www.jdatepicker.com for further information or send us your suggestions.

Copyright © 2003-2007 Stand By Soft Ltd. All Rights Reserved.