java.lang.Objectjavax.swing.AbstractSpinnerModel
javax.swing.SpinnerDateModel
All Implemented Interfaces:
Serializable, SpinnerModel
SpinnerModel for sequences of Dates.
The upper and lower bounds of the sequence are defined by properties called
start and end and the size
of the increase or decrease computed by the nextValue
and previousValue methods is defined by a property
called calendarField. The start
and end properties can be null to
indicate that the sequence has no lower or upper limit.
The value of the calendarField property must be one of the
java.util.Calendar constants that specify a field
within a Calendar. The getNextValue
and getPreviousValue
methods change the date forward or backwards by this amount.
For example, if calendarField is Calendar.DAY_OF_WEEK,
then nextValue produces a Date that's 24
hours after the current value, and previousValue
produces a Date that's 24 hours earlier.
The legal values for calendarField are:
Calendar.ERA
Calendar.YEAR
Calendar.MONTH
Calendar.WEEK_OF_YEAR
Calendar.WEEK_OF_MONTH
Calendar.DAY_OF_MONTH
Calendar.DAY_OF_YEAR
Calendar.DAY_OF_WEEK
Calendar.DAY_OF_WEEK_IN_MONTH
Calendar.AM_PM
Calendar.HOUR
Calendar.HOUR_OF_DAY
Calendar.MINUTE
Calendar.SECOND
Calendar.MILLISECOND
This model inherits a ChangeListener. The
ChangeListeners are notified whenever the models
value, calendarField,
start, or end properties changes.
Hans - Muller1.4 - | Fields inherited from javax.swing.AbstractSpinnerModel: |
|---|
| listenerList |
| Constructor: |
|---|
SpinnerDateModel whose initial
value is the current date, calendarField
is equal to Calendar.DAY_OF_MONTH, and for which
there are no start/end limits. |
SpinnerDateModel that represents a sequence of dates
between start and end. The
nextValue and previousValue methods
compute elements of the sequence by advancing or reversing
the current date value by the
calendarField time unit. For a precise description
of what it means to increment or decrement a Calendar
field, see the add method in
java.util.Calendar.
The
|
| Method from javax.swing.SpinnerDateModel Summary: |
|---|
| getCalendarField, getDate, getEnd, getNextValue, getPreviousValue, getStart, getValue, setCalendarField, setEnd, setStart, setValue |
| Methods from javax.swing.AbstractSpinnerModel: |
|---|
| addChangeListener, fireStateChanged, getChangeListeners, getListeners, removeChangeListener |
| Methods from java.lang.Object: |
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from javax.swing.SpinnerDateModel Detail: |
|---|
Calendar field that is added to or subtracted from
by the nextValue and previousValue methods. |
Dates.
This method is equivalent to (Date)getValue. |
Date in the sequence. |
Date in the sequence, or null if
the next date is after end. |
Date in the sequence, or null
if the previous date is before start. |
Date in the sequence. |
Dates. |
nextValue and previousValue methods.
The calendarField parameter must be one of the
Calendar field constants like Calendar.MONTH
or Calendar.MINUTE.
The nextValue and previousValue methods
simply move the specified Calendar field forward or backward
by one unit with the Calendar.add method.
You should use this method with care as some UIs may set the
calendarField before commiting the edit to spin the field under
the cursor. If you only want one field to spin you can subclass
and ignore the setCalendarField calls. |
Dates in this sequence.
If start is null, then there is no upper
limit. No bounds checking is done here: the new
start value may invalidate the (start <= value <= end)
invariant enforced by the constructors. This is to simplify updating
the model. Naturally, one should ensure that the invariant is true
before calling the nextValue, previousValue,
or setValue methods.
Typically this property is a
This method fires a |
start is null,
then there is no lower limit. No bounds checking is done here:
the new start value may invalidate the
(start <= value <= end)
invariant enforced by the constructors. This is to simplify updating
the model. Naturally one should ensure that the invariant is true
before calling the nextValue, previousValue,
or setValue methods.
Typically this property is a
MyStartDate implements Comparable {
long t = 12345;
public int compareTo(Date d) {
return (t < d.getTime() ? -1 : (t == d.getTime() ? 0 : 1));
}
public int compareTo(Object o) {
return compareTo((Date)o);
}
}
Note that the above example will throw a ClassCastException
if the Object passed to compareTo(Object)
is not a Date.
This method fires a |
Date for this sequence.
If value is null,
an IllegalArgumentException is thrown. No bounds
checking is done here:
the new value may invalidate the (start <= value < end)
invariant enforced by the constructors. Naturally, one should ensure
that the (start <= value <= maximum) invariant is true
before calling the nextValue, previousValue,
or setValue methods.
This method fires a |