org.tentackle.ui
Class DateFormField

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.text.JTextComponent
                  extended by javax.swing.JTextField
                      extended by org.tentackle.ui.FormField
                          extended by org.tentackle.ui.DateFormField
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, SwingConstants, FormComponent, FormFieldComponent

public class DateFormField
extends FormField

FormField to edit a Date object.

The date can be entered in the specified format or as a shortcut. The following shortcuts are defined:

Furthermore, the date can determined in relation to a reference date by certain commands. By default, the reference date is the current time: The units are the same as described in SimpleDateFormat with some minor differences: The shortcuts (except the units) are locale dependent. In German, for example, the shortcuts are as follows:

Author:
harald
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTextField
JTextField.AccessibleJTextField
 
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class org.tentackle.ui.FormField
ADJUST_LEFT, ADJUST_NONE, ADJUST_RIGHT, ADJUST_TRIM, CONVERT_LC, CONVERT_NONE, CONVERT_UC, errorOffset
 
Fields inherited from class javax.swing.JTextField
notifyAction
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
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 javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DateFormField()
          Creates an empty DateFormField with the default document model and minimum width.
DateFormField(Document doc, int columns)
          Creates an empty DateFormField.
Notice: setting doc != null requires a doc derived from FormFieldDocument.
DateFormField(int columns)
          Creates an empty DateFormField with the default document model.
DateFormField(String pattern)
          Creates an empty DateFormField with the default document model, mininum width and a given format.
 
Method Summary
 String doFormat(Object date)
          Does the formatting of the given object.
Renders the object and returns the string.
 Date getDate()
          Gets the SQL-Date.
 String getFormat()
          Gets the format string.
 Date getFormValue()
          Retrieves the value from this component.
The method is used to update the data if the view has changed because the user edited it.
 Date getReferenceDate()
          Gets the reference date for the input shortcuts.
 Time getTime()
          Gets the SQL-Time.
 Timestamp getTimestamp()
          Gets the SQL-Timestamp.
 boolean isLenient()
          Returns the lenient flag for the date format
 void setFormat(String pattern)
          Sets the format string.
The format string is used to format the view of the data.
 void setFormValue(Object date)
          Sets a value in this component.
The method is used to update the view if the data has changed.
 void setLenient(boolean lenient)
          Sets the "lenient" flag for the date format.
 void setReferenceDate(Date referenceDate)
          Sets the reference date for the input shortcuts.
 
Methods inherited from class org.tentackle.ui.FormField
addValueListener, clearText, createDefaultModel, doActionPerformed, downRight, fireValueChanged, fireValueEntered, getAdjust, getConvert, getConverter, getErrorOffset, getFiller, getHelpURL, getInvalidChars, getMaxColumns, getParentWindow, getText, getToolTipText, getValidChars, getVerticalAlignment, invalidateParentInfo, isAutoNext, isAutoSelect, isAutoUpdate, isCaretLeft, isCaretRight, isCellEditorUsage, isChangeable, isEmpty, isEraseFirst, isFireRunning, isFormTraversable, isHonourChangeable, isInhibitAutoSelect, isOverwrite, isStartEditLeftmost, isValueChanged, prepareFocusLost, processFocusEvent, processKeyBinding, removeValueListener, requestFocusLater, saveValue, setAdjust, setAutoNext, setAutoSelect, setAutoUpdate, setCaretLeft, setCaretRight, setCellEditorUsage, setChangeable, setColumns, setConvert, setConverter, setEraseFirst, setFiller, setFireRunning, setFormTraversable, setFormWrapWindow, setHelpURL, setHonourChangeable, setInhibitAutoSelect, setInvalidChars, setMaxColumns, setOverwrite, setStartEditLeftmost, setText, setValidChars, setVerticalAlignment, showHelp, transferFocus, transferFocusBackward, triggerValueChanged, upLeft, wasFocusGainedFromTransfer, wasFocusGainedFromTransferBackward, wasTransferFocus, wasTransferFocusBackward, wasTransferFocusByEnter
 
Methods inherited from class javax.swing.JTextField
actionPropertyChanged, addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setDocument, setFont, setHorizontalAlignment, setScrollOffset
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
 
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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, 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, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, 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, 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, processHierarchyBoundsEvent, processHierarchyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.tentackle.ui.FormFieldComponent
getBaseline, getCaretPosition, getColumns, getHorizontalAlignment, setCaretPosition, setHorizontalAlignment, setToolTipText
 
Methods inherited from interface org.tentackle.ui.FormComponent
hasFocus
 

Constructor Detail

DateFormField

public DateFormField(Document doc,
                     int columns)
Creates an empty DateFormField.
Notice: setting doc != null requires a doc derived from FormFieldDocument.

Parameters:
doc - the document model, null = default
columns - the number of columns, 0 = minimum width

DateFormField

public DateFormField(int columns)
Creates an empty DateFormField with the default document model.

Parameters:
columns - the number of columns, 0 = minimum width

DateFormField

public DateFormField()
Creates an empty DateFormField with the default document model and minimum width.


DateFormField

public DateFormField(String pattern)
Creates an empty DateFormField with the default document model, mininum width and a given format.

Parameters:
pattern - the date format string
Method Detail

setFormValue

public void setFormValue(Object date)
Description copied from interface: FormComponent
Sets a value in this component.
The method is used to update the view if the data has changed.

Parameters:
date - is the object to set

doFormat

public String doFormat(Object date)
Description copied from interface: FormFieldComponent
Does the formatting of the given object.
Renders the object and returns the string.

Parameters:
date - the object
Returns:
the formatted object as a string

getFormValue

public Date getFormValue()
Description copied from interface: FormComponent
Retrieves the value from this component.
The method is used to update the data if the view has changed because the user edited it.

Returns:
the date, null if field is empty

getDate

public Date getDate()
Gets the SQL-Date.

Returns:
the java.sql.Date, null if field is empty

getTimestamp

public Timestamp getTimestamp()
Gets the SQL-Timestamp.

Returns:
the java.sql.Timestamp, null if field is empty

getTime

public Time getTime()
Gets the SQL-Time.

Returns:
the java.sql.Time, null if field is empty

setFormat

public void setFormat(String pattern)
Description copied from interface: FormFieldComponent
Sets the format string.
The format string is used to format the view of the data.

Parameters:
pattern - the format string
See Also:
SimpleDateFormat

getFormat

public String getFormat()
Description copied from interface: FormFieldComponent
Gets the format string.

Returns:
the format string

setLenient

public void setLenient(boolean lenient)
Sets the "lenient" flag for the date format.

Parameters:
lenient - true if lenient
See Also:
SimpleDateFormat

isLenient

public boolean isLenient()
Returns the lenient flag for the date format

Returns:
true if lenient

getReferenceDate

public Date getReferenceDate()
Gets the reference date for the input shortcuts.

Returns:
the reference date for input shortcuts, null = now (default)

setReferenceDate

public void setReferenceDate(Date referenceDate)
Sets the reference date for the input shortcuts.

Parameters:
referenceDate - reference date for input shortcuts, null = now


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de