com.lavantech.gui.comp
Class CalendarPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bycom.lavantech.gui.comp.CalendarPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class CalendarPanel
extends javax.swing.JPanel

CalendarPanel displays a given calendar. User can select a date. Unavailable dates are disabled for user selection.

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
CalendarPanel()
          Constructs a CalendarPanel with the current date time.
CalendarPanel(java.util.GregorianCalendar cal)
          Constructs a CalendarPanel with the given GregorianCalendar.
CalendarPanel(java.util.GregorianCalendar cal, java.util.Locale locale)
          Constructs a CalendarPanel with the given GregorianCalendar and locale.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener lis)
          Add an action listener that will be notified when the selected date is changed.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a PropertyChangeListener.
 java.util.GregorianCalendar getCalendar()
          Returns the current selected date.
 DateUnavailabilityModel getDateUnavailabilityModel()
          Returns the DateUnavailabilityModel for this class.
 java.util.GregorianCalendar getMaxSelectableDate()
          Returns the maximum date that can be selected in the calendar.
 java.util.GregorianCalendar getMinSelectableDate()
          Returns the minimum date that can be selected in the calendar.
 java.awt.Color getSelectedDayColor()
          Returns the color used to indicate the selected day in the calendar panel.
 java.awt.Color getUnavailableDayColor()
          Returns the color used to indicate unavailable days in the calendar panel.
 boolean isEditable()
          Returns whether the calendar date can be changed by the user or not.
 boolean isEnabled()
          Returns whether the CalendarPanel is enabled or not.
 void removeActionListener(java.awt.event.ActionListener lis)
          Remove an action listener.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a PropertyChangeListener.
 void setBackground(java.awt.Color bg)
          Set the background color of this component.
 void setCalendar(java.util.GregorianCalendar cal)
          Changes the selected date.
 void setDateUnavailabilityModel(DateUnavailabilityModel model)
          Sets the DateUnavailabilityModel for the CalendarPanel.
 void setEditable(boolean edit)
          Sets whether the calendar date can be changed by the user or not.
 void setEnabled(boolean enable)
          Set the CalendarPanel to be enabled or not.
 void setFont(java.awt.Font font)
          Set the font for this Calendar Panel.
 void setForeground(java.awt.Color fg)
          Set the foreground color of this component.
 void setMaxSelectableDate(java.util.GregorianCalendar maxCal)
          Set the maximum date that can be selected with the calendar.
 void setMinSelectableDate(java.util.GregorianCalendar minCal)
          Set the minimum date that can be selected with the calendar.
 void setSelectedDayColor(java.awt.Color color)
          Set the color for the selected day box in the Calendar panel.
 void setToolTipText(java.lang.String text)
          Set the ToolTip Text for this component.
 void setUnavailableDayColor(java.awt.Color color)
          Set the color for the unavailable days in the Calendar panel.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, 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, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, 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, 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

CalendarPanel

public CalendarPanel()
Constructs a CalendarPanel with the current date time.


CalendarPanel

public CalendarPanel(java.util.GregorianCalendar cal)
Constructs a CalendarPanel with the given GregorianCalendar.

Parameters:
cal - The GregorianCalendar that needs to be edited.

CalendarPanel

public CalendarPanel(java.util.GregorianCalendar cal,
                     java.util.Locale locale)
Constructs a CalendarPanel with the given GregorianCalendar and locale.

Parameters:
cal - The GregorianCalendar that needs to be edited.
locale - The Locale that will be used for month and day names.
Method Detail

getMinSelectableDate

public java.util.GregorianCalendar getMinSelectableDate()
Returns the minimum date that can be selected in the calendar. If there is no minimum date limit, null is returned.

Returns:
GregorianCalendar Minimum date that can be selected or null if no minimum limit.

setMinSelectableDate

public void setMinSelectableDate(java.util.GregorianCalendar minCal)
Set the minimum date that can be selected with the calendar. If the current selected date is less than the minimum date, the current selected date is set to the minimum date.

Parameters:
minCal - Minimum date that can be selected in CalendarPanel. null can be passed to remove minimum limit.
Throws:
java.lang.IllegalArgumentException - If minCal is greater than maxSelectableDate
See Also:
setDateUnavailabilityModel(com.lavantech.gui.comp.DateUnavailabilityModel)

getMaxSelectableDate

public java.util.GregorianCalendar getMaxSelectableDate()
Returns the maximum date that can be selected in the calendar. If there is no maximum date limit, null is returned.

Returns:
GregorianCalendar Maximum date that can be selected or null if no maximum limit.

setMaxSelectableDate

public void setMaxSelectableDate(java.util.GregorianCalendar maxCal)
Set the maximum date that can be selected with the calendar. If the current selected date is less than the maximum date, the current selected date is set to the maximum date.

Parameters:
maxCal - Maximum date that can be selected in CalendarPanel. null can be passed to remove maximum limit.
Throws:
java.lang.IllegalArgumentException - If maxCal is less than minSelectableTime
See Also:
setDateUnavailabilityModel(com.lavantech.gui.comp.DateUnavailabilityModel)

isEnabled

public boolean isEnabled()
Returns whether the CalendarPanel is enabled or not.


setEnabled

public void setEnabled(boolean enable)
Set the CalendarPanel to be enabled or not.


isEditable

public boolean isEditable()
Returns whether the calendar date can be changed by the user or not.


setEditable

public void setEditable(boolean edit)
Sets whether the calendar date can be changed by the user or not.


getDateUnavailabilityModel

public DateUnavailabilityModel getDateUnavailabilityModel()
Returns the DateUnavailabilityModel for this class. If no DateUnavailabilityModel is set before, the return value will be null.


setDateUnavailabilityModel

public void setDateUnavailabilityModel(DateUnavailabilityModel model)
Sets the DateUnavailabilityModel for the CalendarPanel.


getCalendar

public java.util.GregorianCalendar getCalendar()
Returns the current selected date.


setCalendar

public void setCalendar(java.util.GregorianCalendar cal)
Changes the selected date. If minSelectableDate or maxSelectableDate was set before and the passed date is beyond the limit, the date limited to the min or max.


setFont

public void setFont(java.awt.Font font)
Set the font for this Calendar Panel.

Parameters:
font - the desired Font for this component

setForeground

public void setForeground(java.awt.Color fg)
Set the foreground color of this component.

Parameters:
fg - the desired foreground Color.

setBackground

public void setBackground(java.awt.Color bg)
Set the background color of this component.

Parameters:
bg - the desired background Color.

setToolTipText

public void setToolTipText(java.lang.String text)
Set the ToolTip Text for this component.

Parameters:
text - the desired ToolTip. If the text is null, the tooltip is turned off.

getUnavailableDayColor

public java.awt.Color getUnavailableDayColor()
Returns the color used to indicate unavailable days in the calendar panel.


setUnavailableDayColor

public void setUnavailableDayColor(java.awt.Color color)
Set the color for the unavailable days in the Calendar panel.


getSelectedDayColor

public java.awt.Color getSelectedDayColor()
Returns the color used to indicate the selected day in the calendar panel.


setSelectedDayColor

public void setSelectedDayColor(java.awt.Color color)
Set the color for the selected day box in the Calendar panel.


addActionListener

public void addActionListener(java.awt.event.ActionListener lis)
Add an action listener that will be notified when the selected date is changed.


removeActionListener

public void removeActionListener(java.awt.event.ActionListener lis)
Remove an action listener.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a PropertyChangeListener.


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a PropertyChangeListener.