net.sf.nachocalendar.components
Class DateField

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bynet.sf.nachocalendar.components.DateField
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable

public class DateField
extends javax.swing.JPanel
implements java.awt.event.ActionListener, java.beans.PropertyChangeListener

Field used to select a date.

Author:
Ignacio Merani
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
DateField()
          Constructs a default DateField.
DateField(boolean showWeekNumbers)
          Creates a new instance of DateField.
DateField(java.text.DateFormat dateFormat)
           
DateField(javax.swing.text.DateFormatter formatter)
          Constructor with a custom formatter.
DateField(java.util.Locale locale)
          Constructor with a custom locale.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Invoked when an action occurs.
 void addChangeListener(javax.swing.event.ChangeListener listener)
          Registers ChangeListener to receive events.
 boolean getAllowsInvalid()
          Getter for property allowsInvalid.
 java.util.Date getBaseDate()
           
 java.text.DateFormat getDateFormat()
           
 int getFirstDayOfWeek()
          Getter for property firstDayOfWeek.
 javax.swing.JFormattedTextField getFormattedTextField()
          Returns the JFormattedTextField for further customization
 HeaderRenderer getHeaderRenderer()
          Getter for property headerRenderer.
 DataModel getModel()
          Getter for property model.
 DayRenderer getRenderer()
          Getter for property renderer.
 boolean getShowOkCancel()
          Getter for property showOkCancel.
 boolean getShowToday()
          Returns the Today button visibility.
 java.lang.String getTodayCaption()
          Returns the today button text.
 java.lang.Object getValue()
          Returns the current Date.
 boolean[] getWorkingDays()
          Getter for property workingDays.
 boolean isAntiAliased()
           
 boolean isEnabled()
          Getter for enabled property
 boolean isPrintMoon()
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Event fired when a property changes.
 void removeChangeListener(javax.swing.event.ChangeListener listener)
          Removes ChangeListener from the list of listeners.
 void setAllowsInvalid(boolean b)
          Setter for property allowsInvalid.
 void setAntiAliased(boolean antiAliased)
           
 void setBaseDate(java.util.Date baseDate)
          A base date may different from "today" and will be the date shown on the Date Window when it is launched.
 void setDateFormat(java.text.DateFormat dateFormat)
           
 void setEnabled(boolean enabled)
          Enables or disables the component
 void setFirstDayOfWeek(int firstDayOfWeek)
          Setter for property firstDayOfWeek.
 void setHeaderRenderer(HeaderRenderer headerRenderer)
          Setter for property headerRenderer.
 void setModel(DataModel model)
          Setter for property model.
 void setPrintMoon(boolean printMoon)
           
 void setRenderer(DayRenderer renderer)
          Setter for property renderer.
 void setShowOkCancel(boolean showOkCancel)
          Setter for property showOkCancel.
 void setShowToday(boolean show)
          Sets the Today button visibility.
 void setTodayCaption(java.lang.String caption)
          Sets the today button text.
 void setValue(java.lang.Object value)
          Sets the current Date.
 void setWorkingDays(boolean[] workingDays)
          Setter for property workingDays.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
 

Constructor Detail

DateField

public DateField(boolean showWeekNumbers)
Creates a new instance of DateField.

Parameters:
showWeekNumbers - true if the week numbers must be shown

DateField

public DateField()
Constructs a default DateField.


DateField

public DateField(javax.swing.text.DateFormatter formatter)
Constructor with a custom formatter.

Parameters:
formatter - formatter used for the textfield

DateField

public DateField(java.text.DateFormat dateFormat)

DateField

public DateField(java.util.Locale locale)
Constructor with a custom locale.

Parameters:
locale - Locale to use
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Invoked when an action occurs.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - the event fired

setValue

public void setValue(java.lang.Object value)
Sets the current Date.

Parameters:
value - current Date

getValue

public java.lang.Object getValue()
Returns the current Date.

Returns:
current Date

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener listener)
Registers ChangeListener to receive events.

Parameters:
listener - The listener to register.

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener listener)
Removes ChangeListener from the list of listeners.

Parameters:
listener - The listener to remove.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Event fired when a property changes.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
evt - event fired

getRenderer

public DayRenderer getRenderer()
Getter for property renderer.

Returns:
Value of property renderer.

setRenderer

public void setRenderer(DayRenderer renderer)
Setter for property renderer.

Parameters:
renderer - New value of property renderer.

getModel

public DataModel getModel()
Getter for property model.

Returns:
Value of property model.

setModel

public void setModel(DataModel model)
Setter for property model.

Parameters:
model - New value of property model.

getHeaderRenderer

public HeaderRenderer getHeaderRenderer()
Getter for property headerRenderer.

Returns:
Value of property headerRenderer.

setHeaderRenderer

public void setHeaderRenderer(HeaderRenderer headerRenderer)
Setter for property headerRenderer.

Parameters:
headerRenderer - New value of property headerRenderer.

getShowOkCancel

public boolean getShowOkCancel()
Getter for property showOkCancel.

Returns:
Value of property showOkCancel.

setShowOkCancel

public void setShowOkCancel(boolean showOkCancel)
Setter for property showOkCancel.

Parameters:
showOkCancel - New value of property showOkCancel.

getAllowsInvalid

public boolean getAllowsInvalid()
Getter for property allowsInvalid.

Returns:
Value of property showOkCancel.

setAllowsInvalid

public void setAllowsInvalid(boolean b)
Setter for property allowsInvalid.


getFirstDayOfWeek

public int getFirstDayOfWeek()
Getter for property firstDayOfWeek.

Returns:
Value of property firstDayOfWeek.

setFirstDayOfWeek

public void setFirstDayOfWeek(int firstDayOfWeek)
Setter for property firstDayOfWeek.

Parameters:
firstDayOfWeek - New value of property firstDayOfWeek.

getWorkingDays

public boolean[] getWorkingDays()
Getter for property workingDays.

Returns:
Value of property workingDays.

setWorkingDays

public void setWorkingDays(boolean[] workingDays)
Setter for property workingDays.

Parameters:
workingDays - New value of property workingDays.

setEnabled

public void setEnabled(boolean enabled)
Enables or disables the component

Parameters:
enabled - true for enabling

isEnabled

public boolean isEnabled()
Getter for enabled property

Returns:
true if it's enabled

getFormattedTextField

public javax.swing.JFormattedTextField getFormattedTextField()
Returns the JFormattedTextField for further customization

Returns:
the JFormattedTextField

isAntiAliased

public boolean isAntiAliased()
Returns:
Returns the antiAliased.

setAntiAliased

public void setAntiAliased(boolean antiAliased)
Parameters:
antiAliased - The antiAliased to set.

isPrintMoon

public boolean isPrintMoon()
Returns:
Returns the printMoon.

setPrintMoon

public void setPrintMoon(boolean printMoon)
Parameters:
printMoon - The printMoon to set.

setShowToday

public void setShowToday(boolean show)
Sets the Today button visibility.

Parameters:
show -

getShowToday

public boolean getShowToday()
Returns the Today button visibility.

Returns:

setTodayCaption

public void setTodayCaption(java.lang.String caption)
Sets the today button text.

Parameters:
caption -

getTodayCaption

public java.lang.String getTodayCaption()
Returns the today button text.

Returns:

getDateFormat

public java.text.DateFormat getDateFormat()
Returns:
Returns the dateFormat.

setDateFormat

public void setDateFormat(java.text.DateFormat dateFormat)
Parameters:
dateFormat - The dateFormat to set.

getBaseDate

public java.util.Date getBaseDate()
Returns:
Returns the baseDate.

setBaseDate

public void setBaseDate(java.util.Date baseDate)
A base date may different from "today" and will be the date shown on the Date Window when it is launched. Basically, a user can have an empty textfield but when the window is open, it won't show today by default but whatever baseDate is. It is backward compatible, ie if you do not have a baseDate, the window will open with "today".

Parameters:
baseDate - The baseDate to set.