JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util.calendar
Class TimeSpin

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JSpinner
                          |
                          +--com.klg.jclass.util.calendar.TimeSpin
All Implemented Interfaces:
CalendarComponent, ChangeListener, EventListener, ImageObserver, JCValueListener, MenuContainer, Serializable

public class TimeSpin
extends JSpinner
implements CalendarComponent, JCValueListener, ChangeListener

The TimeSpin class is used in the DateTimePopup to allow the user to interactively modify the time portion of the current date. In order to get information passed on to it by the DateTimePopup, this class implements the CalendarComponent interface. Note that there are two models, the normal SpinnerModel and the JCValueModel that need to be kept in sync. One holds a Date object and the other holds a Calendar object.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JSpinner
JSpinner.DateEditor, JSpinner.DefaultEditor, JSpinner.ListEditor, JSpinner.NumberEditor
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  com.klg.jclass.util.calendar.BoundsValidator boundsValidator
          A validator that checks for values between a min and max date.
protected  boolean ignoreChange
          Ignore change in spinner if already changing spinner.
protected  com.klg.jclass.util.value.JCValueModel valueModel
          The calendar value model.
 
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
TimeSpin()
          No args constructor.
TimeSpin(Date date)
          Constructor which supplies a starting time (in a Date object).
TimeSpin(Date date, Locale l)
          Constructor which supplies a starting time (in a Date object) and a locale.
 
Method Summary
 void addActionListener(ActionListener l)
          This is unused.
 Calendar getMaximumDate()
          Returns the maximum roll date.
 Calendar getMinimumDate()
          Returns the minimum roll date.
 void removeActionListener(ActionListener l)
          This is unused.
 void setCalendarModel(com.klg.jclass.util.value.JCValueModel valueModel)
          Sets the current date being used by the calendar component.
 void setColumns(int columns)
          Set the number of columns in the editor to a new value.
 void setColumns(SimpleDateFormat sdf)
          Set the columns in the editor to be the pattern size of the passed in SimpleDateFormat.
 void setFont(Font f)
          Sets the font for this component.
 void setFormat(DateFormat df)
          Set the format to use in the JCFormattedTextField for this TimeSpin object.
 void setLocale(Locale l)
          Set the locale the TimeSpin object should use.
 void setMaximumDate(Calendar maxDate)
          Sets the maximum roll date.
 void setMinimumDate(Calendar minDate)
          Sets the minimum date.
 void setModel(SpinnerModel model)
          Overrides JSpinner.setModel(model) so that it can keep both of its models in sync.
 void setSpecialDates(com.klg.jclass.util.calendar.JCCalendar special_dates)
          This is unused.
 void stateChanged(ChangeEvent e)
          The spinner model has changed.
 void valueChanged(com.klg.jclass.util.value.JCValueEvent event)
          The calendar value model has changed.
 void valueChanging(com.klg.jclass.util.value.JCValueEvent event)
          The value is changing.
 
Methods inherited from class javax.swing.JSpinner
addChangeListener, commitEdit, createEditor, fireStateChanged, getChangeListeners, getEditor, getModel, getNextValue, getPreviousValue, getUI, getUIClassID, getValue, removeChangeListener, setEditor, setUI, setValue, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
 

Field Detail

valueModel

protected com.klg.jclass.util.value.JCValueModel valueModel
The calendar value model.


boundsValidator

protected com.klg.jclass.util.calendar.BoundsValidator boundsValidator
A validator that checks for values between a min and max date.


ignoreChange

protected boolean ignoreChange
Ignore change in spinner if already changing spinner.

Constructor Detail

TimeSpin

public TimeSpin()
No args constructor. Use the current time.


TimeSpin

public TimeSpin(Date date)
Constructor which supplies a starting time (in a Date object).

Parameters:
date - The starting time

TimeSpin

public TimeSpin(Date date,
                Locale l)
Constructor which supplies a starting time (in a Date object) and a locale.

Parameters:
date - The starting time
l - The locale to use
Method Detail

setCalendarModel

public void setCalendarModel(com.klg.jclass.util.value.JCValueModel valueModel)
Sets the current date being used by the calendar component. Note that the Calendar component part (which allows it to be part of the DateTimePopup) uses a Calendar value for its model where the spinner uses a SpinnerDateModel (based on a Date). These models are kept in sync.

Specified by:
setCalendarModel in interface CalendarComponent
Parameters:
valueModel - The new calendar value model. This must be of type CalendarValueModel.

setModel

public void setModel(SpinnerModel model)
Overrides JSpinner.setModel(model) so that it can keep both of its models in sync. The Calendar component part (which allows it to be part of the DateTimePopup) uses a Calendar value for its model where the spinner uses a SpinnerDateModel (based on a Date).

Overrides:
setModel in class JSpinner
Parameters:
model - The new model. This must be a SpinnerDateModel.

getMinimumDate

public Calendar getMinimumDate()
Returns the minimum roll date. The calendar cannot change before the date.

Returns:
the minimum date
See Also:
Calendar, setMinimumDate(java.util.Calendar), getMaximumDate(), setMaximumDate(java.util.Calendar)

setMinimumDate

public void setMinimumDate(Calendar minDate)
Sets the minimum date. The calendar cannot change to before this date.

Parameters:
minDate - the new minimum date
See Also:
Calendar, getMinimumDate(), getMaximumDate(), setMaximumDate(java.util.Calendar)

getMaximumDate

public Calendar getMaximumDate()
Returns the maximum roll date. The calendar cannot change later than this date.

Returns:
the maximum date
See Also:
Calendar, setMinimumDate(java.util.Calendar), getMinimumDate(), setMaximumDate(java.util.Calendar)

setMaximumDate

public void setMaximumDate(Calendar maxDate)
Sets the maximum roll date. The calendar cannot change later than this date.

Parameters:
maxDate - the new maximum date
See Also:
Calendar, setMinimumDate(java.util.Calendar), getMinimumDate(), getMaximumDate()

setSpecialDates

public void setSpecialDates(com.klg.jclass.util.calendar.JCCalendar special_dates)
This is unused. Sets the special dates being used by the calendar component.

Specified by:
setSpecialDates in interface CalendarComponent
Parameters:
special_dates - The new list of special dates stored within a JCCalendar object

addActionListener

public void addActionListener(ActionListener l)
This is unused. Adds an action listener to detect specific actions on this component.

Specified by:
addActionListener in interface CalendarComponent
Parameters:
l - The action listener to be added

removeActionListener

public void removeActionListener(ActionListener l)
This is unused. Removes an action listener on this component.

Specified by:
removeActionListener in interface CalendarComponent
Parameters:
l - The action listener to be removed

valueChanging

public void valueChanging(com.klg.jclass.util.value.JCValueEvent event)
The value is changing. Check if the date falls in the min/max bounds.

Specified by:
valueChanging in interface JCValueListener
Parameters:
event - The event generated by the value changing

valueChanged

public void valueChanged(com.klg.jclass.util.value.JCValueEvent event)
The calendar value model has changed. Update the spinner model.

Specified by:
valueChanged in interface JCValueListener
Parameters:
event - The event generated by the value changed

stateChanged

public void stateChanged(ChangeEvent e)
The spinner model has changed. Update the calendar value model.

Specified by:
stateChanged in interface ChangeListener
Parameters:
e - A ChangeEvent object

setLocale

public void setLocale(Locale l)
Set the locale the TimeSpin object should use. Also update the formatter to be based on the new locale.

Specified by:
setLocale in interface CalendarComponent
Overrides:
setLocale in class Component
Parameters:
l - The locale object to use.

setFormat

public void setFormat(DateFormat df)
Set the format to use in the JCFormattedTextField for this TimeSpin object.

Parameters:
df - The new format

setColumns

public void setColumns(SimpleDateFormat sdf)
Set the columns in the editor to be the pattern size of the passed in SimpleDateFormat.

Parameters:
sdf - The format from which to get the pattern size

setColumns

public void setColumns(int columns)
Set the number of columns in the editor to a new value.

Parameters:
columns - The new number of columns (must be non-negative)

setFont

public void setFont(Font f)
Sets the font for this component. Also passes the font on to internal formatted text field.

Overrides:
setFont in class JComponent
Parameters:
f - The desired Font for this component
See Also:
Component.getFont()

Copyright © 2004 Quest Software Inc..
All rights reserved.