ehsbe CommonsTM
Version 1.1.0rc3

com.ehsbe.commons.gui
Class JxTextTimeField

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 javax.swing.JFormattedTextField
                          extended by com.ehsbe.commons.gui.JxTextTimeField
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, SwingConstants

public class JxTextTimeField
extends JFormattedTextField

A textfield for time values.

For Date values use JxDatePicker.

If the dateformat is NOT explicitly set, the underlying Calendar uses the default timezone of this host for calculations.

Version:
$Revision: 432 $
Author:
Jens Elkner
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFormattedTextField
JFormattedTextField.AbstractFormatter, JFormattedTextField.AbstractFormatterFactory
 
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 javax.swing.JFormattedTextField
COMMIT, COMMIT_OR_REVERT, PERSIST, REVERT
 
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
JxTextTimeField()
          Construct an text time field without a validator, but with the default locale.
JxTextTimeField(Class<?> entityClass, String methodName)
          Construct an text time field for the given entity with the default locale.
JxTextTimeField(Class<?> entityClass, String methodName, Locale locale)
          Construct an text time field for the given entity.
JxTextTimeField(Locale locale)
          Construct an text time field.
 
Method Summary
 Calendar getCalendar()
          Get the calendar used for time formatting.
 TimeZone getTimezone()
          Get the associated time zone for this formatter.
 String getToolTipText()
          If tooltip is set to an empty String, this component tries to obtain the Tooltip from its corresponding label.
 Validator<Date> getValidator()
          Get the Validator used to check, whether the fields input is valid.
 Date getValue()
          
protected  void processFocusEvent(FocusEvent e)
          
 void setLocale(Locale l)
          
 void setTemplate(Class<?> entityClass, String methodName)
          Initialize the field wrt. the given entity and method name.
 void setToolTipText(String text)
          
 void setValidator(Validator<Date> validator)
          Set the Validator used to check, whether the fields input is valid.
 void setValue(Object value)
          Same as JFormattedTextField.setValue(java.lang.Object), but normalizes the given time value.
protected  void validate(Date num)
          If a validator is set, this method validates the input and decorates the component, which used this component in a setLabelFor method.
 
Methods inherited from class javax.swing.JFormattedTextField
commitEdit, getActions, getFocusLostBehavior, getFormatter, getFormatterFactory, getUIClassID, invalidEdit, isEditValid, processInputMethodEvent, setDocument, setFocusLostBehavior, setFormatter, setFormatterFactory
 
Methods inherited from class javax.swing.JTextField
actionPropertyChanged, addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setColumns, 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, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, 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, processKeyBinding, 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, 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, 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, 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
 

Constructor Detail

JxTextTimeField

public JxTextTimeField(Class<?> entityClass,
                       String methodName,
                       Locale locale)
Construct an text time field for the given entity.

Parameters:
entityClass - entity class
methodName - name of the method, which should be used to obtain the Column.nullable() for the field
locale - locale to use for obtaining valid number characters
See Also:
setTemplate(Class, String)

JxTextTimeField

public JxTextTimeField()
Construct an text time field without a validator, but with the default locale.


JxTextTimeField

public JxTextTimeField(Locale locale)
Construct an text time field.

Parameters:
locale - locale to use for obtaining valid number characters

JxTextTimeField

public JxTextTimeField(Class<?> entityClass,
                       String methodName)
Construct an text time field for the given entity with the default locale.

Parameters:
entityClass - entity class
methodName - name of the method, which should be used to obtain the Column.nullable() for the field
Method Detail

setTemplate

public void setTemplate(Class<?> entityClass,
                        String methodName)
Initialize the field wrt. the given entity and method name.

If the given method could not be found, has no @Column annotation or the annotation contains not nullable=true, no validator is setup. Otherwise a "not-null"-validator is installed automatically.

Parameters:
entityClass - entity class
methodName - name of the method, which should be used to obtain the Column.nullable() for the field

getTimezone

public TimeZone getTimezone()
Get the associated time zone for this formatter.

Per default this is the default timezone for this host.

Returns:
a time zone

setLocale

public void setLocale(Locale l)

Overrides:
setLocale in class Component

getValue

public Date getValue()

Overrides:
getValue in class JFormattedTextField

setValue

public void setValue(Object value)
Same as JFormattedTextField.setValue(java.lang.Object), but normalizes the given time value. I.e. per default, seconds and milliseconds are set to 0 and the resulting Value represents the time wrt. to the start of the day for the passed value. E.g. if you pass in a date of 01.02.2005 14:30:22,123 the value gets normalized to 01.01.1970 14:30:00,000.

Overrides:
setValue in class JFormattedTextField
See Also:
#parse(String)

getCalendar

public Calendar getCalendar()
Get the calendar used for time formatting. NOTE: Due to locale settings this method does not gurantee to return always the same instance!

Returns:
a calendar instance.

validate

protected void validate(Date num)
If a validator is set, this method validates the input and decorates the component, which used this component in a setLabelFor method.

Parameters:
num - date to validate

getToolTipText

public String getToolTipText()
If tooltip is set to an empty String, this component tries to obtain the Tooltip from its corresponding label.

Overrides:
getToolTipText in class JComponent
Returns:

setToolTipText

public void setToolTipText(String text)

Overrides:
setToolTipText in class JComponent

processFocusEvent

protected void processFocusEvent(FocusEvent e)

Overrides:
processFocusEvent in class JFormattedTextField

getValidator

public Validator<Date> getValidator()
Get the Validator used to check, whether the fields input is valid.

Per default a validator gets automatically installed, if the @Column's nullable property is set to false. It accepts none-null values, only.

Returns:
null if not set, the validator otherwise.

setValidator

public void setValidator(Validator<Date> validator)
Set the Validator used to check, whether the fields input is valid.

Parameters:
validator - null to disable validation, the validator otherwise.

ehsbe CommonsTM
Version 1.1.0rc3

Copyright ©2005-2009 EHSBE, Walther-Rathenau-Str. 58, 39104 Magdeburg, Sachsen-Anhalt, Germany. All Rights Reserved.