JIDE 3.5.15

com.jidesoft.combobox
Class CalendarViewer

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.jidesoft.combobox.CalendarViewer
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class CalendarViewer
extends JPanel

CalendarViewer is a component that can display multiple months and allow you to choose multiple dates across all month viewers.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String PROPERTY_CALENDAR_DIMENSION
           
static String PROPERTY_ENABLED
           
static String PROPERTY_VIEWONLY
           
static String VIEWONLY_PROPERTY
          Property of view only.
 
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
CalendarViewer()
           
CalendarViewer(DateModel model)
           
CalendarViewer(DateModel model, Dimension calendarDimensions)
           
CalendarViewer(Dimension calendarDimensions)
           
 
Method Summary
protected  DateChooserPanel createDateChooserPanel(DateModel dateModel, DateSelectionModel selectionModel)
          Creates a new DateChooserPanel.
protected  void customizeDateChooserPanel(DateChooserPanel dateChooserPanel, int row, int column)
          Customizes the DateChooserPanel.
 Dimension getCalendarDimension()
          Gets the number of rows and columns of months in the DateChooserPanel.
 DateChooserPanel[] getDateChooserPanels()
          Gets the array of DateChooserPanels used by this CalendarViewer.
 DateModel getDateModel()
           
 int getFirstDayOfWeek()
          Gets the first day of the week is; e.g., Sunday in US, Monday in France.
 Calendar getMaxDisplayCalendar()
           
 Calendar getMinDisplayCalendar()
           
 Dimension getMinimumSize()
           
 DateSelectionModel getSelectionModel()
           
 boolean isAutoChangeDimension()
          Checks if autoChangeDimension is true.
 boolean isEnabled()
          If the DateChooserPanel is view-only.
 boolean isViewOnly()
          If the DateChooserPanel is view-only.
 void recalculateCalendarDimension()
          Recalculates the number of rows and columns based on the CalendarViewer's size.
 void setAutoChangeDimension(boolean autoChangeDimension)
          Sets the autoChangeDimension flag.
 void setCalendarDimension(Dimension calendarDimension)
          Sets the number of rows and columns of months in the DateChooserPanel.
 void setDateModel(DateModel dateModel)
           
 boolean setDisplayedMonth(int year, int month)
          Sets the displayed month.
 boolean setDisplayedMonth(int year, int month, int index)
          Sets the displayed month.
 void setEnabled(boolean enabled)
          Sets the view only attribute.
 void setFirstDayOfWeek(int firstDayOfWeek)
          Sets the first day of the week is; e.g., Sunday in US, Monday in France.
 void setSelectionModel(DateSelectionModel selectionModel)
           
 void setViewOnly(boolean viewOnly)
          Sets the view only attribute.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
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, getNextFocusableComponent, getPopupLocation, getPreferredSize, 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, 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

VIEWONLY_PROPERTY

public static final String VIEWONLY_PROPERTY
Property of view only.

See Also:
Constant Field Values

PROPERTY_VIEWONLY

public static final String PROPERTY_VIEWONLY
See Also:
Constant Field Values

PROPERTY_ENABLED

public static final String PROPERTY_ENABLED
See Also:
Constant Field Values

PROPERTY_CALENDAR_DIMENSION

public static final String PROPERTY_CALENDAR_DIMENSION
See Also:
Constant Field Values
Constructor Detail

CalendarViewer

public CalendarViewer()

CalendarViewer

public CalendarViewer(Dimension calendarDimensions)

CalendarViewer

public CalendarViewer(DateModel model)

CalendarViewer

public CalendarViewer(DateModel model,
                      Dimension calendarDimensions)
Method Detail

recalculateCalendarDimension

public void recalculateCalendarDimension()
Recalculates the number of rows and columns based on the CalendarViewer's size.


customizeDateChooserPanel

protected void customizeDateChooserPanel(DateChooserPanel dateChooserPanel,
                                         int row,
                                         int column)
Customizes the DateChooserPanel. By default, this method will hide today and none buttons on all DateChooserPanel. It will also hide next or previous month buttons for most DateChooserPanel and only leave next month button on the on the right-most DateChooserPanel in the first row and previous button on the left-most DateChooserPanel in the first row.

Parameters:
dateChooserPanel - DateChooserPanel to be customized
row - the row index of this DateChooserPanel
column - the column index of this DateChooserPanel

createDateChooserPanel

protected DateChooserPanel createDateChooserPanel(DateModel dateModel,
                                                  DateSelectionModel selectionModel)
Creates a new DateChooserPanel.

Parameters:
dateModel - the data model
selectionModel - the selection model
Returns:
a new DateChooserPanel.

getDateChooserPanels

public DateChooserPanel[] getDateChooserPanels()
Gets the array of DateChooserPanels used by this CalendarViewer.

Returns:
the array of DateChooserPanels used by this CalendarViewer.

getCalendarDimension

public Dimension getCalendarDimension()
Gets the number of rows and columns of months in the DateChooserPanel.

Returns:
the number of rows and columns of months in the DateChooserPanel. Width in the Dimension is the number of rows; height is the number of columns.

setCalendarDimension

public void setCalendarDimension(Dimension calendarDimension)
Sets the number of rows and columns of months in the DateChooserPanel. Width in the Dimension is the number of rows and height is the number of columns. Please note, if isAutoChangeDimension is on, calling to this method will be ignored because the dimension is automatically based on the size of CalendarViewer.

Parameters:
calendarDimension - the calendar dimension

isAutoChangeDimension

public boolean isAutoChangeDimension()
Checks if autoChangeDimension is true.

Returns:
the value of autoChangeDimension flag.

setAutoChangeDimension

public void setAutoChangeDimension(boolean autoChangeDimension)
Sets the autoChangeDimension flag. If true, the number of rows and columns will change automatically when the CalendarViewer size changes. Otherwise, it will resize each DateChooserPanel when the CalendarViewer is resized.

Parameters:
autoChangeDimension - the flag

getMinimumSize

public Dimension getMinimumSize()
Overrides:
getMinimumSize in class JComponent

getMaxDisplayCalendar

public Calendar getMaxDisplayCalendar()

getMinDisplayCalendar

public Calendar getMinDisplayCalendar()

getSelectionModel

public DateSelectionModel getSelectionModel()

setSelectionModel

public void setSelectionModel(DateSelectionModel selectionModel)

getDateModel

public DateModel getDateModel()

setDateModel

public void setDateModel(DateModel dateModel)

setDisplayedMonth

public boolean setDisplayedMonth(int year,
                                 int month)
Sets the displayed month. It will use the first DateChooserPanel to display the specified month if the month is a valid date in the DateModel.

Parameters:
year - the year to be displayed
month - the month to be displayed.
Returns:
whether the new month is displayed successfully. False if the new month is out of the valid range of the getDateModel().

setDisplayedMonth

public boolean setDisplayedMonth(int year,
                                 int month,
                                 int index)
Sets the displayed month. It will use the specified DateChooserPanel as in parameter index to display the specified month if the month is a valid date in the DateModel.

Parameters:
year - the year to be displayed
month - the month to be displayed.
index - the index of the DateChooserPanel to display the specified month.
Returns:
whether the new month is displayed successfully. False if the new month is out of the valid range of the getDateModel().

isViewOnly

public boolean isViewOnly()
If the DateChooserPanel is view-only.

Returns:
true if the DateChooserPanel is view-only

setViewOnly

public void setViewOnly(boolean viewOnly)
Sets the view only attribute. If the DateChooserPanel is view-only, user will not be able to change the month or year once it's set.

Parameters:
viewOnly - the flag

isEnabled

public boolean isEnabled()
If the DateChooserPanel is view-only.

Overrides:
isEnabled in class Component
Returns:
true if the DateChooserPanel is view-only

setEnabled

public void setEnabled(boolean enabled)
Sets the view only attribute. If the DateChooserPanel is view-only, user will not be able to change the month or year once it's set.

Overrides:
setEnabled in class JComponent
Parameters:
enabled - the flag

getFirstDayOfWeek

public int getFirstDayOfWeek()
Gets the first day of the week is; e.g., Sunday in US, Monday in France.

Returns:
firstDayOfWeek. -1 if you never set before. If so, the default value in the locale will be used.

setFirstDayOfWeek

public void setFirstDayOfWeek(int firstDayOfWeek)
Sets the first day of the week is; e.g., Sunday in US, Monday in France. The values are defined in Calendar such as Calendar.SUNDAY, Calendar.MONDAY etc.

Parameters:
firstDayOfWeek - the first day of the week

JIDE 3.5.15