uic.widgets.calendar
Class UICDateEdit

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by uic.widgets.calendar.UICDateEdit
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class UICDateEdit
extends JComponent

A widget for selecting or entering a date.

The UICDateEdit widget has the looks of a combo box. Per default it is non-editable as shown here: , but it can also be set to be editable, as is shown here: .

When the UICDateEdit button is clicked it pops up a UICDatePicker that stays open until a date is selected on the date picker's calendar, or until the popup is cancelled.

If a locale is specified the DateEdit will display it's date in that format. For example: If the Dutch locale is specified the UICDateEdit button looks like this: . This locale is also passed on to the date picker in the popup.

Since:
2.0
Author:
Stefan Rotman
See Also:
Serialized Form

Nested Class Summary
protected  class UICDateEdit.UICDatePickerButton
           
 
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.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String PROPERTY_DATECHANGE
          This field can be used for listening to propertyChange events this widget fires.
 
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
  UICDateEdit()
          Constructs a new UICDateEdit with the default model.
  UICDateEdit(Locale locale, Calendar cal)
          Constructs a new UICDateEdit with the specified locale and Calendar to use as selected date.
protected UICDateEdit(UICCalendarModel model)
          Constructs a new UICDateEdit that uses the specified model.
 
Method Summary
 void dateFieldInputDoneSlot()
          Called when a date is entered in the dateField.
 void datePickerSelectedSlot()
          Called when a date was selected in the datePicker
 Dimension getMaximumSize()
           
 UICCalendarModel getModel()
          Returns the UICCalendarModel for this DateEdit.
 Calendar getSelectedCalendar()
          Returns the date (Calendar) that is the current value.
 boolean getShowWeekNrs()
          Returns whether or not weeknumbers are shown in the datepicker popup
 boolean isEditable()
          Returns whether or not this is an editable UICDateEdit.
static void main(String[] args)
           
 void pickerButtonClickedSlot()
          Called when the button was clicked.
 void setEditable(boolean editable)
          Sets the UICDateEdit to editable or not.
 void setEnabled(boolean enable)
          En- or disable all components in the UICDateEdit.
 void setSelectedCalendar(Calendar cal)
          Sets the current date (Calendar) for this widget.
 void setShowWeekNrs(boolean showWeekNrs)
          Turn weeknumber in the datepicker popup on or off.
protected  void syncFromModel()
          Syncronize this widget from the UICCalendarModel
 
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, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, 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, 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, setFont, setForeground, 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, 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, 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, removeFocusListener, 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

PROPERTY_DATECHANGE

public static final String PROPERTY_DATECHANGE
This field can be used for listening to propertyChange events this widget fires. By adding a propertyChangeListener (or by creating an PropertyChangedAction) to this widget using this field you will get an event each time the selected date changed.

See Also:
Constant Field Values
Constructor Detail

UICDateEdit

public UICDateEdit()
Constructs a new UICDateEdit with the default model.

See Also:
UICCalendarModel.UICCalendarModel()

UICDateEdit

public UICDateEdit(Locale locale,
                   Calendar cal)
Constructs a new UICDateEdit with the specified locale and Calendar to use as selected date.

Parameters:
locale - the locale to use.
cal - the date to select.
See Also:
UICCalendarModel.UICCalendarModel(Locale,Calendar)

UICDateEdit

protected UICDateEdit(UICCalendarModel model)
Constructs a new UICDateEdit that uses the specified model.

See Also:
UICCalendarModel
Method Detail

setEnabled

public void setEnabled(boolean enable)
En- or disable all components in the UICDateEdit.

Overrides:
setEnabled in class JComponent

setEditable

public void setEditable(boolean editable)
Sets the UICDateEdit to editable or not. If editable the user can enter a date that will be parsed against the UICCalendarModel, but also will have the posibility to use the datepicker popup.

Parameters:
editable - if true the UICDateEdit is set to editable, if false to non-editable.

isEditable

public boolean isEditable()
Returns whether or not this is an editable UICDateEdit.


setShowWeekNrs

public void setShowWeekNrs(boolean showWeekNrs)
Turn weeknumber in the datepicker popup on or off.

Parameters:
showWeekNrs - true to show weeknumbers, false to hide them.

getShowWeekNrs

public boolean getShowWeekNrs()
Returns whether or not weeknumbers are shown in the datepicker popup


datePickerSelectedSlot

public void datePickerSelectedSlot()
Called when a date was selected in the datePicker


syncFromModel

protected void syncFromModel()
Syncronize this widget from the UICCalendarModel


pickerButtonClickedSlot

public void pickerButtonClickedSlot()
Called when the button was clicked.


setSelectedCalendar

public void setSelectedCalendar(Calendar cal)
Sets the current date (Calendar) for this widget.

Parameters:
cal - the calendar to set.

getSelectedCalendar

public Calendar getSelectedCalendar()
Returns the date (Calendar) that is the current value.


dateFieldInputDoneSlot

public void dateFieldInputDoneSlot()
Called when a date is entered in the dateField. Parses the date against the datemodel. If parsing succesfull the new date will be used, otherwise the new value is not used and the old date will again be shown in the datefield.


getModel

public UICCalendarModel getModel()
Returns the UICCalendarModel for this DateEdit.

Returns:
the model

getMaximumSize

public Dimension getMaximumSize()
Overrides:
getMaximumSize in class JComponent

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 2002-2004 Thomas Zander Available under the Free Apache licence