javax.swing
Class SpinnerDateModel
- Serializable, SpinnerModel
A date model used by the
JSpinner
component. This implements a
spinner model for dates, rotating a calendar field such as month, year,
day, week, hour, minute.
int | getCalendarField() - Returns the
Calendar field used to calculate the previous and
next dates in the sequence.
|
Date | getDate() - Returns the current date/time.
|
Comparable<T> | getEnd() - Returns the upper limit on the date/time value, or
null if
there is no maximum date/time.
|
Object | getNextValue() - Returns the next date in the sequence, or
null if the
next date is past the upper limit (if one is specified).
|
Object | getPreviousValue() - Returns the previous date in the sequence, or
null if the
previous date is prior to the lower limit (if one is specified).
|
Comparable<T> | getStart() - Returns the lower limit on the date/time value, or
null if
there is no minimum date/time.
|
Object | getValue() - Returns the current date in the sequence (this method returns the same as
getDate() ).
|
void | setCalendarField(int calendarField) - Sets the date field to change when calculating the next and previous
values.
|
void | setEnd(Comparable<T> end) - Sets the upper limit for the date/time value and, if the new limit is
different to the old limit, sends a
ChangeEvent to all registered
listeners.
|
void | setStart(Comparable<T> start) - Sets the lower limit for the date/time value and, if the new limit is
different to the old limit, sends a
ChangeEvent to all registered
listeners.
|
void | setValue(Object value) - Sets the current date and, if the new value is different to the old
value, sends a
ChangeEvent to all registered listeners.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
SpinnerDateModel
public SpinnerDateModel(Date value,
Comparable<T> start,
Comparable<T> end,
int calendarField)
Constructs a
SpinnerDateModel
with the specified value, lower
and upper bounds, and which spins the specified calendar field.
The
start
and
end
limits must have a
compareTo
method that supports instances of
Date
, but
do not themselves need to be instances of
Date
(although typically
they are).
value
- the initial value/date (null
not permitted).start
- a constraint that specifies the earliest permitted date
value, or null
for no lower limit.end
- a constraint that specifies the latest permitted date value,
or null
for no upper limit.calendarField
- the Calendar
field to spin,
(Calendar.ZONE_OFFSET and Calendar.DST_OFFSET are invalid)
getCalendarField
public int getCalendarField()
Returns the
Calendar
field used to calculate the previous and
next dates in the sequence.
getDate
public Date getDate()
Returns the current date/time.
- The current date/time (never
null
).
getEnd
public Comparable<T> getEnd()
Returns the upper limit on the date/time value, or null
if
there is no maximum date/time.
getNextValue
public Object getNextValue()
Returns the next date in the sequence, or null
if the
next date is past the upper limit (if one is specified). The current date
is not changed.
- getNextValue in interface SpinnerModel
- The next date, or
null
if the current value is
the latest date represented by the model.
getPreviousValue
public Object getPreviousValue()
Returns the previous date in the sequence, or null
if the
previous date is prior to the lower limit (if one is specified). The
current date is not changed.
- getPreviousValue in interface SpinnerModel
- The previous date, or
null
if the current value is
the earliest date represented by the model.
getStart
public Comparable<T> getStart()
Returns the lower limit on the date/time value, or null
if
there is no minimum date/time.
setCalendarField
public void setCalendarField(int calendarField)
calendarField
- the calendar field to set.
setEnd
public void setEnd(Comparable<T> end)
Sets the upper limit for the date/time value and, if the new limit is
different to the old limit, sends a
ChangeEvent
to all registered
listeners. A
null
value is interpreted as "no upper limit".
No check is made to ensure that the current date/time is on or before the
new upper limit - the caller is responsible for ensuring that this
relationship holds. In addition, the caller should ensure that
end
is
Serializable
.
end
- the new upper limit for the date/time value (null
permitted).
setStart
public void setStart(Comparable<T> start)
Sets the lower limit for the date/time value and, if the new limit is
different to the old limit, sends a
ChangeEvent
to all registered
listeners. A
null
value is interpreted as "no lower limit".
No check is made to ensure that the current date/time is on or after the
new lower limit - the caller is responsible for ensuring that this
relationship holds. In addition, the caller should ensure that
start
is
Serializable
.
start
- the new lower limit for the date/time value
(null
permitted).
setValue
public void setValue(Object value)
Sets the current date and, if the new value is different to the old
value, sends a
ChangeEvent
to all registered listeners.
- setValue in interface SpinnerModel
value
- the new date (null
not permitted, must be an
instance of Date
).
SpinnerDateModel.java --
Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.