com.toedter.calendar

Class JSpinnerDateEditor

Implemented Interfaces:
ChangeListener, FocusListener, IDateEditor

public class JSpinnerDateEditor
extends JSpinner
implements IDateEditor, FocusListener, ChangeListener

JSpinnerDateEditor is a date editor based on a JSpinner.
Version:
$LastChangedRevision: 100 $, $LastChangedDate: 2006-06-04 14:36:06 +0200 (So, 04 Jun 2006) $
Author:
Kai Toedter

Field Summary

protected Date
date
protected String
dateFormatString
protected SimpleDateFormat
dateFormatter

Constructor Summary

JSpinnerDateEditor()

Method Summary

void
focusGained(FocusEvent e)
void
focusLost(FocusEvent focusEvent)
Date
getDate()
Returns the date.
String
getDateFormatString()
Returns tha date format string.
Date
getMaxSelectableDate()
Gets the minimum selectable date.
Date
getMinSelectableDate()
JComponent
getUiComponent()
Returns the UI component, e.g.
void
setDate(Date date)
Sets the date.
void
setDate(Date date, boolean updateModel)
void
setDateFormatString(String dateFormatString)
Sets the date format string, e.g.
void
setEnabled(boolean b)
Enables and disabled the compoment.
void
setLocale(Locale locale)
Sets the locale.
void
setMaxSelectableDate(Date max)
void
setMinSelectableDate(Date min)
void
setSelectableDateRange(Date min, Date max)
void
stateChanged(ChangeEvent e)

Field Details

date

protected Date date

dateFormatString

protected String dateFormatString

dateFormatter

protected SimpleDateFormat dateFormatter

Constructor Details

JSpinnerDateEditor

public JSpinnerDateEditor()

Method Details

focusGained

public void focusGained(FocusEvent e)

focusLost

public void focusLost(FocusEvent focusEvent)

getDate

public Date getDate()
Returns the date.
Specified by:
getDate in interface IDateEditor
Returns:
the date

getDateFormatString

public String getDateFormatString()
Returns tha date format string.
Specified by:
getDateFormatString in interface IDateEditor
Returns:
the date format string

getMaxSelectableDate

public Date getMaxSelectableDate()
Gets the minimum selectable date.
Specified by:
getMaxSelectableDate in interface IDateEditor
Returns:
the minimum selectable date

getMinSelectableDate

public Date getMinSelectableDate()
Specified by:
getMinSelectableDate in interface IDateEditor

getUiComponent

public JComponent getUiComponent()
Returns the UI component, e.g. the actual JTextField implementing the editor.
Specified by:
getUiComponent in interface IDateEditor
Returns:
the UI component

setDate

public void setDate(Date date)
Sets the date. This should be implemented as a bound property, firing the "date" property.
Specified by:
setDate in interface IDateEditor
Parameters:
date - the date to set

setDate

public void setDate(Date date,
                    boolean updateModel)

setDateFormatString

public void setDateFormatString(String dateFormatString)
Sets the date format string, e.g. "MM/dd/yy". If the date format string is null or invalid, the date format string will be set to the MEDIUM Simple date format of the current locale.
Specified by:
setDateFormatString in interface IDateEditor
Parameters:
dateFormatString - the date format string

setEnabled

public void setEnabled(boolean b)
Enables and disabled the compoment. It also fixes the background bug 4991597 and sets the background explicitely to a TextField.inactiveBackground.
Specified by:
setEnabled in interface IDateEditor

setLocale

public void setLocale(Locale locale)
Sets the locale. Usually this should have impact on the current date format string.
Specified by:
setLocale in interface IDateEditor
Parameters:
locale - the locale to set

setMaxSelectableDate

public void setMaxSelectableDate(Date max)
Specified by:
setMaxSelectableDate in interface IDateEditor
See Also:
com.toedter.calendar.IDateEditor.setMaxSelectableDate(java.util.Date)

setMinSelectableDate

public void setMinSelectableDate(Date min)
Specified by:
setMinSelectableDate in interface IDateEditor
See Also:
com.toedter.calendar.IDateEditor.setMinSelectableDate(java.util.Date)

setSelectableDateRange

public void setSelectableDateRange(Date min,
                                   Date max)
Specified by:
setSelectableDateRange in interface IDateEditor
See Also:
com.toedter.calendar.IDateEditor.setSelectableDateRange(java.util.Date, java.util.Date)

stateChanged

public void stateChanged(ChangeEvent e)
See Also:
javax.swing.event.ChangeListener.stateChanged(javax.swing.event.ChangeEvent)

Copyright B) 1999 - 2009 Kai Toedter.