net.sf.nachocalendar.components
Class CalendarPanel

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

public class CalendarPanel
extends javax.swing.JPanel
implements javax.swing.event.ChangeListener

Panel used to show many months at once.

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
static int DOWN
          Down Position.
protected  boolean eternalScroll
           
static int HORIZONTAL
          Horizontal orientation.
static int LEFT
          Left Position.
static int RIGHT
          Right Position.
static int UP
          Up Position.
static int VERTICAL
          Vertical orientation.
 
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()
          Default constructor, constructs a vertical panel with 3 months.
CalendarPanel(boolean showWeekNumbers)
          Constructrs a panel with 3 months, Vertical.
CalendarPanel(int quantity)
          Constructs a panel with 3 months and the provided orientation.
CalendarPanel(int quantity, int orientation)
          Constructs a panel with the provided quantity and orientation.
CalendarPanel(int quantity, int orientation, boolean showWeekNumber)
           
CalendarPanel(int quantity, int orientation, boolean showWeekNumber, boolean eternalScroll)
          Creates a new instance of CalendarPanel.
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener listener)
          Registers ChangeListener to receive events.
 void addKeyListener(java.awt.event.KeyListener listener)
          Registers KeyListener to receive events.
 java.util.Date getDate()
          Getter for property date.
 DateSelectionModel getDateSelectionModel()
           
 int getFirstDayOfWeek()
          Getter for property firstDayOfWeek.
 HeaderRenderer getHeaderRenderer()
          Getter for property headerRenderer.
 int getMinimalDaysInFirstWeek()
           
 DataModel getModel()
          Getter for property model.
 int getOrientation()
          Getter for property orientation.
 int getQuantity()
          Getter for property quantity.
 DayRenderer getRenderer()
          Getter for property renderer.
 int getScrollPosition()
          Getter for property scrollPosition.
 int getSelectionMode()
           
 java.lang.Object getValue()
          Returns the selected date.
 java.lang.Object[] getValues()
          Return the selected dates as an Array.
 boolean[] getWorkingdays()
          Getter for property workingdays.
 int getYearPosition()
          Getter for property yearPosition.
 boolean isAntiAliased()
           
 boolean isEnabled()
          Getter for enabled property
 boolean isEternalScroll()
           
 boolean isPrintMoon()
           
 boolean isShowToday()
           
 void refresh()
          Refreshes the display of this month.
 void removeChangeListener(javax.swing.event.ChangeListener listener)
          Removes ChangeListener from the list of listeners.
 void removeKeyListener(java.awt.event.KeyListener listener)
          Removes KeyListener from the list of listeners.
 void setAntiAliased(boolean antiAliased)
           
 void setDate(java.util.Date date)
          Setter for property date.
 void setDateSelectionModel(DateSelectionModel dateSelectionModel)
           
 void setEnabled(boolean enabled)
          Enables or disables the component
 void setEternalScroll(boolean eternalScroll)
           
 void setFirstDayOfWeek(int firstDayOfWeek)
          Setter for property firstDayOfWeek.
 void setHeaderRenderer(HeaderRenderer headerRenderer)
          Setter for property headerRenderer.
 void setMinimalDaysInFirstWeek(int number)
          Specifies how many days should the first week of the year contain
If not specified, i.e.
 void setModel(DataModel model)
          Setter for property model.
 void setOrientation(int orientation)
          Changes the orientation (horizontal or vertical).
 void setPrintMoon(boolean printMoon)
           
 void setQuantity(int quantity)
          Setter for property quantity.
 void setRenderer(DayRenderer renderer)
          Setter for property renderer.
 void setScrollPosition(int scrollPosition)
          Setter for property scrollPosition.
 void setSelectionMode(int selectionMode)
           
 void setShowToday(boolean showToday)
           
 void setTodayCaption(java.lang.String caption)
           
 void setValue(java.lang.Object date)
          Sets the selected date.
 void setValues(java.lang.Object[] dates)
          Set the selected dates.
 void setWorkingdays(boolean[] workingdays)
          Setter for property workingdays.
 void setYearPosition(int yearPosition)
          Setter for property yearPosition.
 void stateChanged(javax.swing.event.ChangeEvent e)
          Event fired when the selected day changes.
 
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, 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, 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
 

Field Detail

eternalScroll

protected boolean eternalScroll

HORIZONTAL

public static final int HORIZONTAL
Horizontal orientation.

See Also:
Constant Field Values

VERTICAL

public static final int VERTICAL
Vertical orientation.

See Also:
Constant Field Values

LEFT

public static final int LEFT
Left Position.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Right Position.

See Also:
Constant Field Values

UP

public static final int UP
Up Position.

See Also:
Constant Field Values

DOWN

public static final int DOWN
Down Position.

See Also:
Constant Field Values
Constructor Detail

CalendarPanel

public CalendarPanel()
Default constructor, constructs a vertical panel with 3 months.


CalendarPanel

public CalendarPanel(int quantity)
Constructs a panel with 3 months and the provided orientation.

Parameters:
quantity - quantity of months to show at once

CalendarPanel

public CalendarPanel(boolean showWeekNumbers)
Constructrs a panel with 3 months, Vertical.

Parameters:
showWeekNumbers -

CalendarPanel

public CalendarPanel(int quantity,
                     int orientation)
Constructs a panel with the provided quantity and orientation.

Parameters:
quantity - months to show at once
orientation - orientation

CalendarPanel

public CalendarPanel(int quantity,
                     int orientation,
                     boolean showWeekNumber)

CalendarPanel

public CalendarPanel(int quantity,
                     int orientation,
                     boolean showWeekNumber,
                     boolean eternalScroll)
Creates a new instance of CalendarPanel.

Parameters:
showWeekNumber - true to show the week numbers
quantity - months to show at once
orientation - the orientation
Method Detail

setOrientation

public void setOrientation(int orientation)
Changes the orientation (horizontal or vertical).

Parameters:
orientation - the new orientation

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.

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
Event fired when the selected day changes.

Specified by:
stateChanged in interface javax.swing.event.ChangeListener
Parameters:
e - event fired

getDate

public java.util.Date getDate()
Getter for property date.

Returns:
Value of property date.

setDate

public void setDate(java.util.Date date)
Setter for property date.

Parameters:
date - New value of property date.

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.

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.

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.

refresh

public void refresh()
Refreshes the display of this month.


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.

getOrientation

public int getOrientation()
Getter for property orientation.

Returns:
Value of property orientation.

getScrollPosition

public int getScrollPosition()
Getter for property scrollPosition.

Returns:
Value of property scrollPosition.

setScrollPosition

public void setScrollPosition(int scrollPosition)
Setter for property scrollPosition.

Parameters:
scrollPosition - New value of property scrollPosition.

getYearPosition

public int getYearPosition()
Getter for property yearPosition.

Returns:
Value of property yearPosition.

setYearPosition

public void setYearPosition(int yearPosition)
Setter for property yearPosition.

Parameters:
yearPosition - New value of property yearPosition.

getQuantity

public int getQuantity()
Getter for property quantity.

Returns:
Value of property quantity.

setQuantity

public void setQuantity(int quantity)
Setter for property quantity.

Parameters:
quantity - New value of property quantity.

addKeyListener

public void addKeyListener(java.awt.event.KeyListener listener)
Registers KeyListener to receive events.

Parameters:
listener - The listener to register.

removeKeyListener

public void removeKeyListener(java.awt.event.KeyListener listener)
Removes KeyListener from the list of listeners.

Parameters:
listener - The listener to remove.

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

isAntiAliased

public boolean isAntiAliased()
Returns:
Returns the antiAliased.

setAntiAliased

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

getSelectionMode

public int getSelectionMode()
Returns:
Returns the selectionMode.

setSelectionMode

public void setSelectionMode(int selectionMode)
Parameters:
selectionMode - The selectionMode to set.

getValue

public java.lang.Object getValue()
Returns the selected date.

Returns:
Selected Date

getValues

public java.lang.Object[] getValues()
Return the selected dates as an Array.

Returns:
Selected Dates

setValue

public void setValue(java.lang.Object date)
Sets the selected date.

Parameters:
date - Date to select

setValues

public void setValues(java.lang.Object[] dates)
Set the selected dates.

Parameters:
dates - Array with the Dates

getDateSelectionModel

public DateSelectionModel getDateSelectionModel()
Returns:
Returns the dateSelectionModel.

setDateSelectionModel

public void setDateSelectionModel(DateSelectionModel dateSelectionModel)
Parameters:
dateSelectionModel - The dateSelectionModel to set.

setMinimalDaysInFirstWeek

public void setMinimalDaysInFirstWeek(int number)
Specifies how many days should the first week of the year contain
If not specified, i.e. 0, then no changes from the defaults are done

Parameters:
number -

getMinimalDaysInFirstWeek

public int getMinimalDaysInFirstWeek()
Returns:
how many weekdays does the first week of the year have

isPrintMoon

public boolean isPrintMoon()
Returns:
Returns the printMoon.

setPrintMoon

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

setTodayCaption

public void setTodayCaption(java.lang.String caption)

isEternalScroll

public boolean isEternalScroll()
Returns:
Returns the eternalScroll.

setEternalScroll

public void setEternalScroll(boolean eternalScroll)
Parameters:
eternalScroll - The eternalScroll to set.

isShowToday

public boolean isShowToday()
Returns:
Returns the showToday.

setShowToday

public void setShowToday(boolean showToday)
Parameters:
showToday - The showToday to set.