Diamond Control Suite 3.0

diamondedge.swing
Class DsDatePicker

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by diamondedge.swing.DsDatePicker
All Implemented Interfaces:
ActionListener, KeyListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener

public class DsDatePicker
extends JComponent
implements ActionListener, PropertyChangeListener, KeyListener

DsDatePicker displays a drop down DsDateView to select a date visually using a calendar style component. The date can also be edited directly by typing into the date field.

See Also:
Serialized Form

Nested Class Summary
 
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
static int CUSTOM_FORMAT
          Display date and time using the format string specified in the 'CustomFormat' property.
protected  JFormattedTextField field
           
static int FULL_DATE
          Display date in full format, for example 'Monday, September 2, 1974'.
static int FULL_DATE_TIME
          Display date and time in full format, for example 'Monday, September 2, 1974 5:31:42 PM MST'.
static int LONG_DATE
          Display date in long format, for example 'September 2, 1974'.
static int LONG_DATE_TIME
          Display date and time in long format, for example 'September 2, 1974 5:31:42 PM MST'.
static int MEDIUM_DATE
          Display date in medium format, for example 'Sep 2, 1974'.
static int MEDIUM_DATE_TIME
          Display date and time in medium format, for example 'Sep 2, 1974 5:31 PM'.
static int SHORT_DATE
          Display date in short format, for example '9/2/74'.
static int SHORT_DATE_TIME
          Display date and time in short format, for example '9/2/74 5:31 PM'.
 
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
DsDatePicker()
           
DsDatePicker(Calendar displayDate, Locale locale)
           
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void addActionListener(ActionListener l)
           
 Calendar getCalendar()
          Returns a Calendar object containing the currently selected date.
 String getCustomFormat()
          Returns a format string used to set the date format when the Format property is set to CUSTOM_FORMAT.
 Date getDate()
          Returns a Date object containing the currently selected date.
 boolean getDateOnly()
          Returns whether the time portion should be always set to 0.
 int getFormat()
          Determines whether dates and times are displayed using standard or custom formatting.
 Locale getLocale()
          Gets the locale of this component.
 boolean isAlwaysValid()
          Returns whether the text input always represents a valid date according to the Format property.
 boolean isFocusOwner()
           
 boolean isNullAllowed()
          Returns whether a null date is allowed.
 void keyPressed(KeyEvent e)
           
 void keyReleased(KeyEvent e)
           
 void keyTyped(KeyEvent e)
           
 void propertyChange(PropertyChangeEvent e)
           
 void removeActionListener(ActionListener l)
           
 void setAlwaysValid(boolean alwaysValid)
          Sets whether the text input always represents a valid date according to the Format property.
 void setCalendar(Calendar date)
          Sets the date to be displayed.
 void setCustomFormat(String customFormat)
          Sets the format string used to set the date format when the Format property is set to CUSTOM_FORMAT.
 void setDate(Date date)
          Sets the date to be displayed.
 void setDateFormat(DateFormat dateFormat)
          Sets the format object used to display the date.
 void setDateOnly(boolean dateOnly)
          Sets whether the time portion should be always set to 0.
static void setDefaultAlwaysValid(boolean b)
          Sets the default value for all newly created DsDatePickers as to whether the text input always represents a valid date according to the Format property.
 void setEnabled(boolean b)
           
 void setFont(Font f)
           
 void setFormat(int val)
          Determines whether dates and times are displayed using standard or custom formatting.
 void setLocale(Locale locale)
          Sets the locale of this component.
 void setNullAllowed(boolean allowNull)
          Sets whether a null date is allowed.
 void setToolTipText(String text)
          Sets the text for the ToolTip of the editor to the given text.
 void updateUI()
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, 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, 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, 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, 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
 

Field Detail

SHORT_DATE

public static final int SHORT_DATE
Display date in short format, for example '9/2/74'.

See Also:
Constant Field Values

MEDIUM_DATE

public static final int MEDIUM_DATE
Display date in medium format, for example 'Sep 2, 1974'.

See Also:
Constant Field Values

LONG_DATE

public static final int LONG_DATE
Display date in long format, for example 'September 2, 1974'.

See Also:
Constant Field Values

FULL_DATE

public static final int FULL_DATE
Display date in full format, for example 'Monday, September 2, 1974'.

See Also:
Constant Field Values

SHORT_DATE_TIME

public static final int SHORT_DATE_TIME
Display date and time in short format, for example '9/2/74 5:31 PM'.

See Also:
Constant Field Values

MEDIUM_DATE_TIME

public static final int MEDIUM_DATE_TIME
Display date and time in medium format, for example 'Sep 2, 1974 5:31 PM'.

See Also:
Constant Field Values

LONG_DATE_TIME

public static final int LONG_DATE_TIME
Display date and time in long format, for example 'September 2, 1974 5:31:42 PM MST'.

See Also:
Constant Field Values

FULL_DATE_TIME

public static final int FULL_DATE_TIME
Display date and time in full format, for example 'Monday, September 2, 1974 5:31:42 PM MST'.

See Also:
Constant Field Values

CUSTOM_FORMAT

public static final int CUSTOM_FORMAT
Display date and time using the format string specified in the 'CustomFormat' property.

See Also:
Constant Field Values

field

protected JFormattedTextField field
Constructor Detail

DsDatePicker

public DsDatePicker()

DsDatePicker

public DsDatePicker(Calendar displayDate,
                    Locale locale)
Method Detail

updateUI

public void updateUI()
Overrides:
updateUI in class JComponent

setEnabled

public void setEnabled(boolean b)
Overrides:
setEnabled in class JComponent

isFocusOwner

public boolean isFocusOwner()
Overrides:
isFocusOwner in class Component

getCalendar

public Calendar getCalendar()
Returns a Calendar object containing the currently selected date. If nothing is selected, it returns the date on the popdown calendar (current date or last date set).


setCalendar

public void setCalendar(Calendar date)
Sets the date to be displayed.


getDate

public Date getDate()
Returns a Date object containing the currently selected date. Returns null if nothing selected.


setDate

public void setDate(Date date)
Sets the date to be displayed.


getLocale

public Locale getLocale()
Gets the locale of this component.

Overrides:
getLocale in class Component
Returns:
this component's locale; if this component does not have a locale, the locale of its parent is returned or the default locale.

setLocale

public void setLocale(Locale locale)
Sets the locale of this component. Also changes the DateFormat property based on the setting for the Format property.

Overrides:
setLocale in class Component
See Also:
setFormat(int)

setDateFormat

public void setDateFormat(DateFormat dateFormat)
Sets the format object used to display the date. This overrides and is an alternative to the Format property.

See Also:
setFormat(int)

getFormat

public int getFormat()
Determines whether dates and times are displayed using standard or custom formatting.


setFormat

public void setFormat(int val)
Determines whether dates and times are displayed using standard or custom formatting.
   SHORT_DATE       - Short Date Format (for example "9/2/74").
   MEDIUM_DATE      - Long Date Format (for example "Sep 2, 1974").
   LONG_DATE        - Long Date Format (for example "September 2, 1974").
   FULL_DATE        - Full Date Format (for example "Monday, September 2, 1974").
   SHORT_DATE_TIME  - Short Date, Short Time Format (for example "9/2/74 5:31 PM").
   MEDIUM_DATE_TIME - Medium Date, Short Time Format (for example "Sep 2, 1974 5:31 PM").
   LONG_DATE_TIME   - Long Date, Long Time Format (for example "September 2, 1974 5:31:42 PM MST").
   FULL_DATE_TIME   - Full Date, Full Time Format (for example "Monday, September 2, 1974 5:31:42 PM MST").
   CUSTOM_FORMAT    - Custom format (see CustomFormat property).
This is a convenience method that calls setDateFormat with the appropriate DateFormat instance. You can call setDateFormat directly with any other format combinations such as: DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.SHORT )

See Also:
setDateFormat(java.text.DateFormat)

getCustomFormat

public String getCustomFormat()
Returns a format string used to set the date format when the Format property is set to CUSTOM_FORMAT.


setCustomFormat

public void setCustomFormat(String customFormat)
Sets the format string used to set the date format when the Format property is set to CUSTOM_FORMAT. The string is used to create an instance of SimpleDateFormat.

See Also:
setFormat(int), setDateFormat(java.text.DateFormat)

setDefaultAlwaysValid

public static void setDefaultAlwaysValid(boolean b)
Sets the default value for all newly created DsDatePickers as to whether the text input always represents a valid date according to the Format property.

See Also:
setAlwaysValid(boolean)

isAlwaysValid

public boolean isAlwaysValid()
Returns whether the text input always represents a valid date according to the Format property.


setAlwaysValid

public void setAlwaysValid(boolean alwaysValid)
Sets whether the text input always represents a valid date according to the Format property. If set to true: If set to false:

See Also:
setFormat(int)

isNullAllowed

public boolean isNullAllowed()
Returns whether a null date is allowed.


setNullAllowed

public void setNullAllowed(boolean allowNull)
Sets whether a null date is allowed. If false then a date will always be displayed.


getDateOnly

public boolean getDateOnly()
Returns whether the time portion should be always set to 0.


setDateOnly

public void setDateOnly(boolean dateOnly)
Sets whether the time portion should be always set to 0. This is also set to the appropriate value in setFormat in all but the CUSTOM_FORMAT setting.

See Also:
setFormat(int)

setFont

public void setFont(Font f)
Overrides:
setFont in class JComponent

setToolTipText

public void setToolTipText(String text)
Sets the text for the ToolTip of the editor to the given text. In english locales the default text is the format string or date pattern. If no ToolTip is desired then this property will need to be set to null after the Format or DateFormat has been set.

Overrides:
setToolTipText in class JComponent

addActionListener

public void addActionListener(ActionListener l)

removeActionListener

public void removeActionListener(ActionListener l)

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

keyPressed

public void keyPressed(KeyEvent e)
Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(KeyEvent e)
Specified by:
keyReleased in interface KeyListener

keyTyped

public void keyTyped(KeyEvent e)
Specified by:
keyTyped in interface KeyListener

propertyChange

public void propertyChange(PropertyChangeEvent e)
Specified by:
propertyChange in interface PropertyChangeListener

Diamond Control Suite 3.0

Diamond Edge and Diamond Control Suite are trademarks or registered trademarks of Diamond Edge, Inc. Copyright 1999-2005 Diamond Edge, Inc. All Rights Reserved.