JDatePicker v4.3.25

com.standbysoft.component.date.swing.binding
Class DateEditComponentAdapter

java.lang.Object
  extended by com.standbysoft.component.date.DefaultDateModel
      extended by com.standbysoft.component.date.swing.binding.DateEditComponentAdapter
All Implemented Interfaces:
DateModel

public class DateEditComponentAdapter
extends DefaultDateModel

Converts ValueModels to the DateModel interface. Useful to bind JDateEditComponents to a ValueModel.

Example:

 ValueModel model = new PropertyAdapter(book, "published", date);
 JDateField publishedDateField = new JDateField();
 publishedDateField.setDateModel(new DateEditComponentAdapter(model, publishedDateField.getdateModel()));
 publishedDateField.commitEdit();
 


Field Summary
 
Fields inherited from class com.standbysoft.component.date.DefaultDateModel
FIELDS
 
Constructor Summary
DateEditComponentAdapter(com.jgoodies.binding.value.ValueModel subject, DateModel dateModel)
          Constructs a DateEditComponentAdapter on the given subject for the specified choice.
 
Method Summary
static void bind(JDateEditComponent dateEditComponent, com.jgoodies.binding.value.ValueModel model)
          Binds a date edit component to a specified value model.
 java.util.Date getDate()
          Returns the date wrapped by this model.
 int getMaximumAllowed(int field, java.util.Date date)
          Returns the highest acceptable value for a certain field.
 int getMinimumAllowed(int field, java.util.Date date)
          Always returns 0.
 void setDate(java.util.Date date)
          Specifies a new date to be represented by this model that can later be modified field by field.
 
Methods inherited from class com.standbysoft.component.date.DefaultDateModel
addDateListener, clear, fireDateChanged, fireDateFieldChanged, fireDateFieldCleared, get, getAutoCenturyYear, getTimeZone, isAutoCentury, isDateValid, isSet, isUsed, removeDateListener, set, setAutoCentury, setAutoCenturyYear, setTimeZone, setUsed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateEditComponentAdapter

public DateEditComponentAdapter(com.jgoodies.binding.value.ValueModel subject,
                                DateModel dateModel)
Constructs a DateEditComponentAdapter on the given subject for the specified choice.

Parameters:
subject - the subject that holds the value
dateModel - the date model of the date edit component that is bounded
Throws:
java.lang.NullPointerException - if the subject is null
Method Detail

setDate

public void setDate(java.util.Date date)
Description copied from interface: DateModel
Specifies a new date to be represented by this model that can later be modified field by field. A null date will clear all the basic fields like Calendar.YEAR, Calendar.MONTH, Calendar.DATE, Calendar.HOUR, Calendar.MINUTE, Calendar.SECOND and Calendar.MILLISECOND.

Specified by:
setDate in interface DateModel
Overrides:
setDate in class DefaultDateModel
Parameters:
date - date wrapped by the model
See Also:
DateModel.clear(int)

getDate

public java.util.Date getDate()
Description copied from interface: DateModel
Returns the date wrapped by this model. If there are missing fields and the date cannot be computed then a null date is returned.

Specified by:
getDate in interface DateModel
Overrides:
getDate in class DefaultDateModel
Returns:
date wrapped by this model.
See Also:
DefaultDateModel.isDateValid()

getMaximumAllowed

public int getMaximumAllowed(int field,
                             java.util.Date date)
Description copied from interface: DateModel
Returns the highest acceptable value for a certain field. For some fields like day of month, this value might depend on other date fields. For instance, the days in a month depend on the month and in the case of February, they also depend on the year.

Specified by:
getMaximumAllowed in interface DateModel
Overrides:
getMaximumAllowed in class DefaultDateModel
Parameters:
field - field that is tested
date - context object that can offer additional information about the other date fields
Returns:
highest acceptable value for a certain field, like 59 for the minute field
See Also:
DateModel.set(int, int)

getMinimumAllowed

public int getMinimumAllowed(int field,
                             java.util.Date date)
Description copied from class: DefaultDateModel
Always returns 0. The minimum accepted value for this default implementation is aloways 0.

Specified by:
getMinimumAllowed in interface DateModel
Overrides:
getMinimumAllowed in class DefaultDateModel
Parameters:
field - field that is tested
date - context object that can offer additional information about the other date fields
Returns:
lowest acceptable value for a certain field, like 0 for the minute field
See Also:
DateModel.set(int, int)

bind

public static void bind(JDateEditComponent dateEditComponent,
                        com.jgoodies.binding.value.ValueModel model)
Binds a date edit component to a specified value model.

Parameters:
dateEditComponent - component that is binded to a value model
model - value model where the component is binded

JDatePicker v4.3.25

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

Copyright © 2003-2010 Elmro Ltd. All Rights Reserved.