com.toedter.calendar
Class JSpinnerDateEditor

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JSpinner
                  extended by com.toedter.calendar.JSpinnerDateEditor
All Implemented Interfaces:
IDateEditor, java.awt.event.FocusListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener

public class JSpinnerDateEditor
extends javax.swing.JSpinner
implements IDateEditor, java.awt.event.FocusListener, javax.swing.event.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
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JSpinner
javax.swing.JSpinner.AccessibleJSpinner, javax.swing.JSpinner.DateEditor, javax.swing.JSpinner.DefaultEditor, javax.swing.JSpinner.ListEditor, javax.swing.JSpinner.NumberEditor
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.util.Date date
           
protected  java.lang.String dateFormatString
           
protected  java.text.SimpleDateFormat dateFormatter
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JSpinnerDateEditor()
           
 
Method Summary
 void focusGained(java.awt.event.FocusEvent e)
           
 void focusLost(java.awt.event.FocusEvent focusEvent)
           
 java.util.Date getDate()
          Returns the date.
 java.lang.String getDateFormatString()
          Returns tha date format string.
 java.util.Date getMaxSelectableDate()
          Gets the minimum selectable date.
 java.util.Date getMinSelectableDate()
          Gets the maximum selectable date.
 javax.swing.JComponent getUiComponent()
          Returns the UI component, e.g.
 void setDate(java.util.Date date)
          Sets the date.
 void setDate(java.util.Date date, boolean updateModel)
           
 void setDateFormatString(java.lang.String dateFormatString)
          Sets the date format string, e.g.
 void setEnabled(boolean b)
          Enables and disabled the compoment.
 void setLocale(java.util.Locale locale)
          Sets the locale.
 void setMaxSelectableDate(java.util.Date max)
          Sets the maximum selectable date.
 void setMinSelectableDate(java.util.Date min)
          Sets the minimum selectable date.
 void setSelectableDateRange(java.util.Date min, java.util.Date max)
          Sets a valid date range for selectable dates.
 void stateChanged(javax.swing.event.ChangeEvent e)
           
 
Methods inherited from class javax.swing.JSpinner
addChangeListener, commitEdit, createEditor, fireStateChanged, getAccessibleContext, getChangeListeners, getEditor, getModel, getNextValue, getPreviousValue, getUI, getUIClassID, getValue, removeChangeListener, setEditor, setModel, setUI, setValue, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.toedter.calendar.IDateEditor
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener
 

Field Detail

date

protected java.util.Date date

dateFormatString

protected java.lang.String dateFormatString

dateFormatter

protected java.text.SimpleDateFormat dateFormatter
Constructor Detail

JSpinnerDateEditor

public JSpinnerDateEditor()
Method Detail

getDate

public java.util.Date getDate()
Description copied from interface: IDateEditor
Returns the date.

Specified by:
getDate in interface IDateEditor
Returns:
the date

setDate

public void setDate(java.util.Date date)
Description copied from interface: IDateEditor
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(java.util.Date date,
                    boolean updateModel)

setDateFormatString

public void setDateFormatString(java.lang.String dateFormatString)
Description copied from interface: IDateEditor
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

getDateFormatString

public java.lang.String getDateFormatString()
Description copied from interface: IDateEditor
Returns tha date format string.

Specified by:
getDateFormatString in interface IDateEditor
Returns:
the date format string

getUiComponent

public javax.swing.JComponent getUiComponent()
Description copied from interface: IDateEditor
Returns the UI component, e.g. the actual JTextField implementing the editor.

Specified by:
getUiComponent in interface IDateEditor
Returns:
the UI component

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: IDateEditor
Sets the locale. Usually this should have impact on the current date format string.

Specified by:
setLocale in interface IDateEditor
Overrides:
setLocale in class java.awt.Component
Parameters:
locale - the locale to set

focusLost

public void focusLost(java.awt.event.FocusEvent focusEvent)
Specified by:
focusLost in interface java.awt.event.FocusListener

focusGained

public void focusGained(java.awt.event.FocusEvent e)
Specified by:
focusGained in interface java.awt.event.FocusListener

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
Overrides:
setEnabled in class javax.swing.JComponent
Parameters:
b - true, if the UI component should be enabled.

getMaxSelectableDate

public java.util.Date getMaxSelectableDate()
Description copied from interface: IDateEditor
Gets the minimum selectable date.

Specified by:
getMaxSelectableDate in interface IDateEditor
Returns:
the minimum selectable date

getMinSelectableDate

public java.util.Date getMinSelectableDate()
Description copied from interface: IDateEditor
Gets the maximum selectable date.

Specified by:
getMinSelectableDate in interface IDateEditor
Returns:
the maximum selectable date
See Also:
IDateEditor.getMinSelectableDate()

setMaxSelectableDate

public void setMaxSelectableDate(java.util.Date max)
Description copied from interface: IDateEditor
Sets the maximum selectable date.

Specified by:
setMaxSelectableDate in interface IDateEditor
Parameters:
max - maximum selectable date
See Also:
IDateEditor.setMaxSelectableDate(java.util.Date)

setMinSelectableDate

public void setMinSelectableDate(java.util.Date min)
Description copied from interface: IDateEditor
Sets the minimum selectable date.

Specified by:
setMinSelectableDate in interface IDateEditor
Parameters:
min - minimum selectable date
See Also:
IDateEditor.setMinSelectableDate(java.util.Date)

setSelectableDateRange

public void setSelectableDateRange(java.util.Date min,
                                   java.util.Date max)
Description copied from interface: IDateEditor
Sets a valid date range for selectable dates. If max is before min, the default range with no limitation is set.

Specified by:
setSelectableDateRange in interface IDateEditor
Parameters:
min - the minimum selectable date or null (then the minimum date should be set to 01\01\0001)
max - the maximum selectable date or null (then the maximum date should be set to 01\01\9999)
See Also:
IDateEditor.setSelectableDateRange(java.util.Date, java.util.Date)

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
Specified by:
stateChanged in interface javax.swing.event.ChangeListener
See Also:
ChangeListener.stateChanged(javax.swing.event.ChangeEvent)


Copyright ? 1999 - 2006 Kai Toedter.