com.alee.extended.date
Class WebCalendar

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.alee.laf.panel.WebPanel
                      extended by com.alee.extended.date.WebCalendar
All Implemented Interfaces:
PartialDecoration, LanguageContainerMethods, ShapeProvider, Styleable, SizeMethods<WebPanel>, SwingMethods, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class WebCalendar
extends WebPanel

This is a custom calendar component.

Author:
Mikle Garin
See Also:
WebDateField, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
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  boolean animate
          Whether should animate month transitions or not.
protected  java.awt.Color currentMonthForeground
          Current month date buttons foreground.
protected  java.util.Date date
          Currently selected date.
protected  DateCustomizer dateCustomizer
          Date buttons customizer.
protected  java.util.List<DateSelectionListener> dateSelectionListeners
          Date selection listeners.
protected  boolean horizontalSlide
          Whether should perform horizontal slide animation or not.
protected  WebToggleButton lastSelectedDayButton
           
protected  WebPanel monthDays
           
protected  ComponentTransition monthDaysTransition
           
protected  WebButton next
           
static javax.swing.ImageIcon nextIcon
           
protected  WebButton nextSkip
           
static javax.swing.ImageIcon nextSkipIcon
           
protected  java.util.Date oldShownDate
          Previously displayed month date.
protected  java.awt.Color otherMonthForeground
          Other month date buttons foreground.
protected  WebButton previous
           
static javax.swing.ImageIcon previousIcon
           
protected  WebButton previousSkip
          UI components.
static javax.swing.ImageIcon previousSkipIcon
          Used icons.
protected  java.util.Date shownDate
          Displayed month date.
protected  boolean startWeekFromSunday
          Whether sunday should be the first day of week or not.
protected  java.text.SimpleDateFormat titleFormat
          Calendar title format.
protected  WebLabel titleLabel
           
protected  ComponentTransition titlePanel
           
protected  java.awt.Color weekendsForeground
          Weekends date buttons foreground.
protected  WebPanel weekHeaders
           
 
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
WebCalendar()
          Constructs new calendar without selected date.
WebCalendar(java.util.Date date)
          Constructs new calendar with the specified selected date.
 
Method Summary
 void addDateSelectionListener(DateSelectionListener listener)
          Adds date selection listener.
protected  void changeMonth(int change)
          Changes displayed month.
protected  void changeYear(int change)
          Changes displayed year.
protected  WebPanel createMonthPanel()
          Creates and returns month panel.
protected  WebLabel createTitleLabel()
          Creates and returns title label.
 void fireDateSelected(java.util.Date date)
          Informs about date selection change.
 java.awt.Color getCurrentMonthForeground()
          Returns current month date buttons foreground.
 java.util.Date getDate()
          Returns currently selected date.
 DateCustomizer getDateCustomizer()
          Returns date buttons customizer.
protected  Direction getNextDirection(boolean ltr)
          Returns next month transition direction.
 java.awt.Color getOtherMonthForeground()
          Returns other month date buttons foreground.
protected  Direction getPrevDirection(boolean ltr)
          Returns previous month transition direction.
 java.util.Date getShownDate()
          Returns displayed month date.
 java.text.SimpleDateFormat getTitleFormat()
          Returns title format.
 java.awt.Color getWeekendsForeground()
          Returns weekends date buttons foreground.
 boolean isAnimate()
          Returns whether should animate month transitions or not.
 boolean isHorizontalSlide()
          Returns whether should perform horizontal slide animation or not.
 boolean isStartWeekFromSunday()
          Returns whether sunday should be the first day of week or not.
 void removeDateSelectionListener(DateSelectionListener listener)
          Removes date selection listener.
protected  void requestFocusToSelected()
          Requests focus to last selected date button.
 void setAnimate(boolean animate)
          Sets whether should animate month transitions or not.
 void setCurrentMonthForeground(java.awt.Color color)
          Sets current month date buttons foreground.
 void setDate(java.util.Date date)
          Sets currently selected and displayed date.
 void setDate(java.util.Date date, boolean animate)
          Sets currently selected and displayed date.
 void setDateCustomizer(DateCustomizer dateCustomizer)
          Sets date buttons customizer.
protected  void setDateImpl(java.util.Date date)
          Sets currently selected and displayed date.
protected  void setDateImpl(java.util.Date date, boolean animate)
          Sets currently selected and displayed date.
 void setEnabled(boolean enabled)
          
 void setHorizontalSlide(boolean horizontalSlide)
          Sets whether should perform horizontal slide animation or not.
 void setOtherMonthForeground(java.awt.Color color)
          Sets other month date buttons foreground.
 void setShownDate(java.util.Date date)
          Sets displayed month date.
 void setShownDate(java.util.Date date, boolean animate)
          Sets displayed month date.
 void setStartWeekFromSunday(boolean startWeekFromSunday)
          Sets whether sunday should be the first day of week or not.
 void setTitleFormat(java.text.SimpleDateFormat titleFormat)
          Sets title format.
 void setWeekendsForeground(java.awt.Color color)
          Sets weekends date buttons foreground.
protected  void switchMonth(boolean animate)
          Switches view to new displayed month.
protected  void switchTitleLabel()
          Switches to new title label.
protected  void updateMonth(javax.swing.JPanel monthDays)
          Updates displayed month date buttons.
protected  void updateTitleLabel()
          Updates title label text.
protected  void updateWeekHeaders()
          Updates week headers.
 
Methods inherited from class com.alee.laf.panel.WebPanel
add, add, add, add, add, add, getBorderColor, getBorderStroke, getDisabledBorderColor, getFirstComponent, getLanguageContainerKey, getLastComponent, getMargin, getMinimumHeight, getMinimumWidth, getPainter, getPreferredHeight, getPreferredSize, getPreferredWidth, getRound, getShadeTransparency, getShadeWidth, getStyleId, getWebUI, isPaintBackground, isPaintBottom, isPaintBottomLine, isPaintFocus, isPaintLeft, isPaintLeftLine, isPaintRight, isPaintRightLine, isPaintTop, isPaintTopLine, isUndecorated, isWebColoredBackground, provideShape, removeLanguageContainerKey, setBorderColor, setBorderStroke, setDisabledBorderColor, setLanguageContainerKey, setMargin, setMargin, setMargin, setMinimumHeight, setMinimumWidth, setPaintBackground, setPaintBottom, setPaintBottomLine, setPainter, setPaintFocus, setPaintLeft, setPaintLeftLine, setPaintRight, setPaintRightLine, setPaintSideLines, setPaintSides, setPaintTop, setPaintTopLine, setPreferredHeight, setPreferredWidth, setRound, setShadeTransparency, setShadeWidth, setStyleId, setUndecorated, setWebColoredBackground, updateUI
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI
 
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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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
 
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

previousSkipIcon

public static final javax.swing.ImageIcon previousSkipIcon
Used icons.


previousIcon

public static final javax.swing.ImageIcon previousIcon

nextIcon

public static final javax.swing.ImageIcon nextIcon

nextSkipIcon

public static final javax.swing.ImageIcon nextSkipIcon

dateSelectionListeners

protected java.util.List<DateSelectionListener> dateSelectionListeners
Date selection listeners.


titleFormat

protected java.text.SimpleDateFormat titleFormat
Calendar title format. Usually displays currently visible month and year.


startWeekFromSunday

protected boolean startWeekFromSunday
Whether sunday should be the first day of week or not.


animate

protected boolean animate
Whether should animate month transitions or not.


horizontalSlide

protected boolean horizontalSlide
Whether should perform horizontal slide animation or not. todo Replace with transition panel customizer


otherMonthForeground

protected java.awt.Color otherMonthForeground
Other month date buttons foreground.


currentMonthForeground

protected java.awt.Color currentMonthForeground
Current month date buttons foreground.


weekendsForeground

protected java.awt.Color weekendsForeground
Weekends date buttons foreground.


dateCustomizer

protected DateCustomizer dateCustomizer
Date buttons customizer.


date

protected java.util.Date date
Currently selected date.


shownDate

protected java.util.Date shownDate
Displayed month date.


oldShownDate

protected java.util.Date oldShownDate
Previously displayed month date. Used to perform animation in a specific direction.


previousSkip

protected WebButton previousSkip
UI components.


previous

protected WebButton previous

titlePanel

protected ComponentTransition titlePanel

titleLabel

protected WebLabel titleLabel

next

protected WebButton next

nextSkip

protected WebButton nextSkip

weekHeaders

protected WebPanel weekHeaders

monthDays

protected WebPanel monthDays

monthDaysTransition

protected ComponentTransition monthDaysTransition

lastSelectedDayButton

protected WebToggleButton lastSelectedDayButton
Constructor Detail

WebCalendar

public WebCalendar()
Constructs new calendar without selected date.


WebCalendar

public WebCalendar(java.util.Date date)
Constructs new calendar with the specified selected date.

Parameters:
date - selected date
Method Detail

createTitleLabel

protected WebLabel createTitleLabel()
Creates and returns title label.

Returns:
created title label

switchTitleLabel

protected void switchTitleLabel()
Switches to new title label. In case animation is disabled simply changes title text.


updateTitleLabel

protected void updateTitleLabel()
Updates title label text.


changeMonth

protected void changeMonth(int change)
Changes displayed month.

Parameters:
change - months change amount

changeYear

protected void changeYear(int change)
Changes displayed year.

Parameters:
change - years change amount

createMonthPanel

protected WebPanel createMonthPanel()
Creates and returns month panel.

Returns:
created month panel

switchMonth

protected void switchMonth(boolean animate)
Switches view to new displayed month.

Parameters:
animate - whether should animate transition or not

requestFocusToSelected

protected void requestFocusToSelected()
Requests focus to last selected date button.


getNextDirection

protected Direction getNextDirection(boolean ltr)
Returns next month transition direction.

Parameters:
ltr - whether LTR orientation or not
Returns:
next month transition direction

getPrevDirection

protected Direction getPrevDirection(boolean ltr)
Returns previous month transition direction.

Parameters:
ltr - whether LTR orientation or not
Returns:
previous month transition direction

updateWeekHeaders

protected void updateWeekHeaders()
Updates week headers.


updateMonth

protected void updateMonth(javax.swing.JPanel monthDays)
Updates displayed month date buttons.

Parameters:
monthDays - panel to update

getTitleFormat

public java.text.SimpleDateFormat getTitleFormat()
Returns title format.

Returns:
title format

setTitleFormat

public void setTitleFormat(java.text.SimpleDateFormat titleFormat)
Sets title format.

Parameters:
titleFormat - title format

getDate

public java.util.Date getDate()
Returns currently selected date.

Returns:
currently selected date

setDate

public void setDate(java.util.Date date)
Sets currently selected and displayed date.

Parameters:
date - date to select and display

setDate

public void setDate(java.util.Date date,
                    boolean animate)
Sets currently selected and displayed date.

Parameters:
date - date to select and display
animate - whether should animate month transition or not

setDateImpl

protected void setDateImpl(java.util.Date date)
Sets currently selected and displayed date.

Parameters:
date - date to select and display

setDateImpl

protected void setDateImpl(java.util.Date date,
                           boolean animate)
Sets currently selected and displayed date.

Parameters:
date - date to select and display
animate - whether should animate month transition or not

getShownDate

public java.util.Date getShownDate()
Returns displayed month date.

Returns:
displayed month date

setShownDate

public void setShownDate(java.util.Date date)
Sets displayed month date.

Parameters:
date - displayed month date

setShownDate

public void setShownDate(java.util.Date date,
                         boolean animate)
Sets displayed month date.

Parameters:
date - displayed month date
animate - whether should animate month transition or not

isStartWeekFromSunday

public boolean isStartWeekFromSunday()
Returns whether sunday should be the first day of week or not.

Returns:
true if sunday should be the first day of week, false otherwise

setStartWeekFromSunday

public void setStartWeekFromSunday(boolean startWeekFromSunday)
Sets whether sunday should be the first day of week or not.

Parameters:
startWeekFromSunday - whether sunday should be the first day of week or not

isAnimate

public boolean isAnimate()
Returns whether should animate month transitions or not.

Returns:
true if should animate month transitions, false otherwise

setAnimate

public void setAnimate(boolean animate)
Sets whether should animate month transitions or not.

Parameters:
animate - whether should animate month transitions or not

isHorizontalSlide

public boolean isHorizontalSlide()
Returns whether should perform horizontal slide animation or not.

Returns:
true if should perform horizontal slide animation, false otherwise

setHorizontalSlide

public void setHorizontalSlide(boolean horizontalSlide)
Sets whether should perform horizontal slide animation or not.

Parameters:
horizontalSlide - whether should perform horizontal slide animation or not

getOtherMonthForeground

public java.awt.Color getOtherMonthForeground()
Returns other month date buttons foreground.

Returns:
other month date buttons foreground

setOtherMonthForeground

public void setOtherMonthForeground(java.awt.Color color)
Sets other month date buttons foreground.

Parameters:
color - other month date buttons foreground

getCurrentMonthForeground

public java.awt.Color getCurrentMonthForeground()
Returns current month date buttons foreground.

Returns:
current month date buttons foreground

setCurrentMonthForeground

public void setCurrentMonthForeground(java.awt.Color color)
Sets current month date buttons foreground.

Parameters:
color - current month date buttons foreground

getWeekendsForeground

public java.awt.Color getWeekendsForeground()
Returns weekends date buttons foreground.

Returns:
weekends date buttons foreground

setWeekendsForeground

public void setWeekendsForeground(java.awt.Color color)
Sets weekends date buttons foreground.

Parameters:
color - weekends date buttons foreground

getDateCustomizer

public DateCustomizer getDateCustomizer()
Returns date buttons customizer.

Returns:
date buttons customizer

setDateCustomizer

public void setDateCustomizer(DateCustomizer dateCustomizer)
Sets date buttons customizer.

Parameters:
dateCustomizer - date buttons customizer

setEnabled

public void setEnabled(boolean enabled)

Overrides:
setEnabled in class javax.swing.JComponent

addDateSelectionListener

public void addDateSelectionListener(DateSelectionListener listener)
Adds date selection listener.

Parameters:
listener - date selection listener

removeDateSelectionListener

public void removeDateSelectionListener(DateSelectionListener listener)
Removes date selection listener.

Parameters:
listener - date selection listener

fireDateSelected

public void fireDateSelected(java.util.Date date)
Informs about date selection change.

Parameters:
date - new selected date