test.contrib.tabledatefield
Class DateTextField

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by test.contrib.tabledatefield.DateTextField
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class DateTextField
extends javax.swing.JComponent
implements java.awt.event.ActionListener, javax.accessibility.Accessible

Copyright 2008 Computer Science Software (Pty) Ltd. South Africa. Stripped-down for Substance hover issue demo.

Author:
DP 05-Apr-2003 : Created class (DP)
See Also:
Serialized Form

Nested Class Summary
 
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  javax.swing.JButton calendarButton
           
protected  java.util.Calendar calendarDate
           
protected  DateField dateField
           
protected  javax.swing.JPopupMenu popup
           
protected  boolean popupIsVisible
           
protected  java.sql.Timestamp timestampValue
           
 
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
DateTextField()
           
DateTextField(java.text.SimpleDateFormat dateFormat)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
           
 void addFocusListener(java.awt.event.FocusListener l)
           
 javax.accessibility.AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this DateTextField.
 java.awt.Color getBackground()
           
protected  java.util.Calendar getCurrentCalendarValue()
           
 java.util.Date getDate()
           
 javax.swing.text.Document getDocument()
          Fetches the model associated with the editor.
 DateField getField()
           
 boolean getHasChanged()
           
 java.awt.im.InputMethodRequests getInputMethodRequests()
           
 java.lang.String getText()
           
 java.sql.Timestamp getTimestamp()
           
 boolean isEditable()
          Returns the boolean indicating whether this DateTextField is editable or not.
 void removeFocusListener(java.awt.event.FocusListener l)
           
 void requestFocus()
           
 boolean requestFocusInWindow()
           
 void setBackground(java.awt.Color color)
           
 void setDate(java.util.Date newDate)
           
 void setDocument(javax.swing.text.Document doc)
          Associates the editor with a text document.
 void setEditable(boolean b)
          Sets the specified boolean to indicate whether or not this DateTextField should be editable.
 void setEnabled(boolean flag)
           
protected  void setFieldValue(java.util.Calendar newCalendarDate)
           
 void setForeground(java.awt.Color color)
           
 void setHasChanged(boolean newHasChanged)
           
 void setHorizontalAlignment(int alignment)
           
 void setText(java.lang.String text)
          Override setText() to throw a RuntimeException, setDate() should be used instead.
 
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, getUIClassID, 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, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
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, 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, 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, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, 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

timestampValue

protected java.sql.Timestamp timestampValue

calendarDate

protected java.util.Calendar calendarDate

popup

protected javax.swing.JPopupMenu popup

dateField

protected DateField dateField

popupIsVisible

protected boolean popupIsVisible

calendarButton

protected javax.swing.JButton calendarButton
Constructor Detail

DateTextField

public DateTextField(java.text.SimpleDateFormat dateFormat)

DateTextField

public DateTextField()
Method Detail

getDate

public java.util.Date getDate()

setDate

public void setDate(java.util.Date newDate)

getTimestamp

public java.sql.Timestamp getTimestamp()

setFieldValue

protected void setFieldValue(java.util.Calendar newCalendarDate)

getText

public java.lang.String getText()

setText

public void setText(java.lang.String text)
Override setText() to throw a RuntimeException, setDate() should be used instead.


getField

public DateField getField()

getDocument

public javax.swing.text.Document getDocument()
Fetches the model associated with the editor. This is primarily for the UI to get at the minimal amount of state required to be a text editor. Subclasses will return the actual type of the model which will typically be something that extends Document.

Returns:
the model

setDocument

public void setDocument(javax.swing.text.Document doc)
Associates the editor with a text document. The currently registered factory is used to build a view for the document, which gets displayed by the editor after revalidation. A PropertyChange event ("document") is propagated to each listener.

Parameters:
doc - the document to display/edit
See Also:
getDocument()

setEnabled

public void setEnabled(boolean flag)
Overrides:
setEnabled in class javax.swing.JComponent

setHorizontalAlignment

public void setHorizontalAlignment(int alignment)

setForeground

public void setForeground(java.awt.Color color)
Overrides:
setForeground in class javax.swing.JComponent

setBackground

public void setBackground(java.awt.Color color)
Overrides:
setBackground in class javax.swing.JComponent

getBackground

public java.awt.Color getBackground()
Overrides:
getBackground in class java.awt.Component

getCurrentCalendarValue

protected java.util.Calendar getCurrentCalendarValue()

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

getHasChanged

public boolean getHasChanged()

setHasChanged

public void setHasChanged(boolean newHasChanged)

requestFocus

public void requestFocus()
Overrides:
requestFocus in class javax.swing.JComponent

requestFocusInWindow

public boolean requestFocusInWindow()
Overrides:
requestFocusInWindow in class javax.swing.JComponent

addFocusListener

public void addFocusListener(java.awt.event.FocusListener l)
Overrides:
addFocusListener in class java.awt.Component

removeFocusListener

public void removeFocusListener(java.awt.event.FocusListener l)
Overrides:
removeFocusListener in class java.awt.Component

isEditable

public boolean isEditable()
Returns the boolean indicating whether this DateTextField is editable or not.

Returns:
the boolean value
See Also:
setEditable(boolean)

setEditable

public void setEditable(boolean b)
Sets the specified boolean to indicate whether or not this DateTextField should be editable. A PropertyChange event ("editable") is fired when the state is changed.

Parameters:
b - the boolean to be set
See Also:
isEditable()

getInputMethodRequests

public java.awt.im.InputMethodRequests getInputMethodRequests()
Overrides:
getInputMethodRequests in class java.awt.Component

getAccessibleContext

public javax.accessibility.AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this DateTextField. For text components, the AccessibleContext takes the form of an AccessibleJTextComponent. A new AccessibleJTextComponent instance is created if necessary.

Specified by:
getAccessibleContext in interface javax.accessibility.Accessible
Overrides:
getAccessibleContext in class javax.swing.JComponent
Returns:
an AccessibleJTextComponent that serves as the AccessibleContext of this DateTextField