org.formaria.swing.date
Class DateChooser

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.formaria.swing.date.DateChooser
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, TextHolder, DateListener

public class DateChooser
extends javax.swing.JComponent
implements java.awt.event.ActionListener, DateListener, TextHolder

A panel containing a representation of a month so that the user can select a date visually. Navigation buttons can also be added to allow the previous or following months to be shown.

Copyright (c) Formaria Ltd., 2008, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from Formaria.

$Revision: 1.10 $

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  DateChooserPanel datePanel
           
static int FLAT_MODE
           
protected  javax.swing.JButton nextBtn
           
protected  javax.swing.JButton nextYearBtn
           
protected  javax.swing.JButton prevBtn
           
protected  javax.swing.JButton prevYearBtn
           
static int RAISED_MODE
           
protected  StyleManager styleManager
           
protected  javax.swing.JLabel titlePanel
           
protected  javax.swing.JLabel titleText
           
 
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
DateChooser()
          Sets up a new panel to display the current date.
DateChooser(int mode)
          Sets up a new panel to display the current date.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Reacts to the previous and next buttons by modifying the display.
 void addNavigation(boolean bShow)
          Adds the navigation buttons to the panel.
 java.util.Date getDate()
          Gets the current date.
 java.lang.String getStyle3D()
          Get the style asociated with the 3D elements
 java.lang.String getStyleHighlighted()
          Get the style asociated with the highlighted element
 java.lang.String getStyleSelected()
          Get the style asociated with the selected elements
 java.lang.String getStyleTitle()
          Get the style asociated with the title
 java.lang.String getStyleWeekend()
          Get the style asociated with the weekend element
 java.lang.String getText()
          Get the text/label of a component
 boolean isNavigable()
          Check if the months are navigable by clicking next and previous buttons
 void setDate(java.util.Date newDate)
          Sets the current date.
 void setDayMarker(DayMarker dm)
          Set the day marker service
 void setDayNameStyle(int mode)
          Set the day name style
 void setMarkSelectedDay(boolean state)
          Show or ignore the selected day
 void setMaxDayNameLength(int len)
          Set the minimum length of the day names
 void setMinWeeks(int minWeeks)
          Set the minimum number of weeks to display
 void setNav(boolean nav)
          Add navigation to the panel
 void setNavigable(boolean bShow)
          Set the months as navigable by clicking next and previous buttons
 void setSelectedDay(int day)
          Set the selected day
 void setShowDayNames(boolean state)
          Show or hide the day names
 void setStyle3D(java.lang.String newStyle)
          Get the style asociated with three dimensional objects/elements
 void setStyleHighlighted(java.lang.String newStyle)
          Set the style asociated with highlighted element
 void setStyles(java.lang.String[] styles)
          Set the styles for the date panel
 void setStyleSelected(java.lang.String newStyle)
          Get the style asociated with the selected elements
 void setStyleTitle(java.lang.String newStyle)
          set the style asociated with title element
 void setStyleWeekend(java.lang.String newStyle)
          set the style asociated with weekend element
 void setText(java.lang.String text)
          Set the text/label of a component
 void setTitleFormat(java.lang.String f)
          Set the format of the title date
 
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, setEnabled, 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

RAISED_MODE

public static final int RAISED_MODE
See Also:
Constant Field Values

FLAT_MODE

public static final int FLAT_MODE
See Also:
Constant Field Values

styleManager

protected StyleManager styleManager

titlePanel

protected javax.swing.JLabel titlePanel

titleText

protected javax.swing.JLabel titleText

datePanel

protected DateChooserPanel datePanel

prevBtn

protected javax.swing.JButton prevBtn

nextBtn

protected javax.swing.JButton nextBtn

prevYearBtn

protected javax.swing.JButton prevYearBtn

nextYearBtn

protected javax.swing.JButton nextYearBtn
Constructor Detail

DateChooser

public DateChooser()
Sets up a new panel to display the current date. A title showing the month and year is also added, but the navigation buttons are omitted


DateChooser

public DateChooser(int mode)
Sets up a new panel to display the current date. A title showing the month and year is also added, but the navigation buttons are omitted

Method Detail

addNavigation

public void addNavigation(boolean bShow)
Adds the navigation buttons to the panel. The navigation buttons allow the previous or next month to be displayed


setNav

public void setNav(boolean nav)
Add navigation to the panel

Parameters:
nav - true for navigation controls

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Reacts to the previous and next buttons by modifying the display. The title is also updated to reflect the content

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

getDate

public java.util.Date getDate()
Gets the current date.

Returns:
the date

setDate

public void setDate(java.util.Date newDate)
Sets the current date.

Specified by:
setDate in interface DateListener
Parameters:
newDate - the new date

getStyle3D

public java.lang.String getStyle3D()
Get the style asociated with the 3D elements

Returns:
the style name

setStyle3D

public void setStyle3D(java.lang.String newStyle)
Get the style asociated with three dimensional objects/elements

Parameters:
newStyle - the style name

getStyleTitle

public java.lang.String getStyleTitle()
Get the style asociated with the title

Returns:
the style name

setStyleTitle

public void setStyleTitle(java.lang.String newStyle)
set the style asociated with title element

Parameters:
newStyle - the style name

getStyleSelected

public java.lang.String getStyleSelected()
Get the style asociated with the selected elements

Returns:
the style name

setStyleSelected

public void setStyleSelected(java.lang.String newStyle)
Get the style asociated with the selected elements

Parameters:
newStyle - the style name

getStyleWeekend

public java.lang.String getStyleWeekend()
Get the style asociated with the weekend element

Returns:
the style name

setStyleWeekend

public void setStyleWeekend(java.lang.String newStyle)
set the style asociated with weekend element

Parameters:
newStyle - the style name

getStyleHighlighted

public java.lang.String getStyleHighlighted()
Get the style asociated with the highlighted element

Returns:
the style name

setStyleHighlighted

public void setStyleHighlighted(java.lang.String newStyle)
Set the style asociated with highlighted element

Parameters:
newStyle - the style name

isNavigable

public boolean isNavigable()
Check if the months are navigable by clicking next and previous buttons

Returns:
true if the month can be changed

setNavigable

public void setNavigable(boolean bShow)
Set the months as navigable by clicking next and previous buttons

Parameters:
bShow - true to show the navigation buttons, false to hide them

setText

public void setText(java.lang.String text)
Set the text/label of a component

Specified by:
setText in interface TextHolder
Parameters:
text - the new text

getText

public java.lang.String getText()
Get the text/label of a component

Specified by:
getText in interface TextHolder
Returns:
the component's text

setShowDayNames

public void setShowDayNames(boolean state)
Show or hide the day names

Parameters:
state - true to show the day names

setStyles

public void setStyles(java.lang.String[] styles)
Set the styles for the date panel

Parameters:
styles - the styles in the following order: style, selectedStyle, weekendStyle, highlightStyle, headerStyle, threeDStyle

setTitleFormat

public void setTitleFormat(java.lang.String f)
Set the format of the title date

Parameters:
f - the new format

setMinWeeks

public void setMinWeeks(int minWeeks)
Set the minimum number of weeks to display

Parameters:
minWeeks -

setMaxDayNameLength

public void setMaxDayNameLength(int len)
Set the minimum length of the day names

Parameters:
len - the length of the day names

setDayNameStyle

public void setDayNameStyle(int mode)
Set the day name style

Parameters:
mode - the day name mode

setSelectedDay

public void setSelectedDay(int day)
Set the selected day

Parameters:
day - the selected day

setDayMarker

public void setDayMarker(DayMarker dm)
Set the day marker service

Parameters:
dm -

setMarkSelectedDay

public void setMarkSelectedDay(boolean state)
Show or ignore the selected day

Parameters:
state -