Package com.github.lgooddatepicker.components

## Class CalendarPanel

- java.lang.Object
- - java.awt.Component
  - - java.awt.Container
    - - javax.swing.JComponent
      - - javax.swing.JPanel
        - - com.github.lgooddatepicker.components.CalendarPanel

All Implemented Interfaces:
  `java.awt.image.ImageObserver`, `java.awt.MenuContainer`, `java.io.Serializable`, `javax.accessibility.Accessible`

    public class CalendarPanel
    extends javax.swing.JPanel

CalendarPanel, This implements a swing component that displays and draws a calendar. The CalendarPanel has controls for changing the current month or year, and for selecting dates. In most cases, you will not need to create your own instances of CalendarPanel. The DatePicker class automatically creates its own instances of CalendarPanel whenever the user clicks on the "toggle calendar" button. However, the CalendarPanel can also (optionally) be used as an independent component when desired. The Life cycle of CalendarPanel inside a DatePicker: Each time that the user clicks the toggle calendar button on a date picker, a new CalendarPanel instance is created and displayed, within of a new instance of CustomPopup. The calendar panel instance is closed and disposed each time that the date picker popup is closed.

See Also:
  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

### Fields inherited from class javax.swing.JComponent

`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

`accessibleContext, 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

Constructors
`CalendarPanel()` Constructor, Independent CalendarPanel with default settings.
`CalendarPanel​(DatePicker parentDatePicker)` Constructor, Private CalendarPanel For DatePicker.
`CalendarPanel​(DatePickerSettings settings)` Constructor, Independent CalendarPanel with supplied settings.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addCalendarSelectionListener​(CalendarSelectionListener listener)` addCalendarSelectionListener, This adds a calendar selection listener to this calendar panel.
`void` `drawCalendar()` drawCalendar, This can be called to redraw the calendar.
`java.util.ArrayList<CalendarSelectionListener>` `getCalendarSelectionListeners()` getCalendarSelectionListeners, This returns a new ArrayList, that contains any calendar selection listeners that are registered with this CalendarPanel.
`javax.swing.JButton` `getNextMonthButton()`
`javax.swing.JButton` `getNextYearButton()`
`javax.swing.JButton` `getPreviousMonthButton()`
`javax.swing.JButton` `getPreviousYearButton()`
`java.time.LocalDate` `getSelectedDate()` getSelectedDate, This returns the date that is currently marked as "selected" in the calendar.
`DatePickerSettings` `getSettings()` getSettings, This returns the calendar panel settings instance.
`void` `removeCalendarSelectionListener​(CalendarSelectionListener listener)` removeCalendarSelectionListener, This removes the specified calendar selection listener from this CalendarPanel.
`void` `setDisplayedYearMonth​(java.time.YearMonth yearMonth)` setDisplayedYearMonth, This sets the year and month that is currently displayed in the calendar.
`void` `setLocale​(java.util.Locale locale)` setLocale, The locale for a CalendarPanel should generally be set in the DatePickerSettings.
`void` `setSelectedDate​(java.time.LocalDate selectedDate)` setSelectedDate, This sets a date that will be marked as "selected" in the calendar, and sets the displayed YearMonth to show that date.
`void` `setSelectedDateWithoutShowing​(java.time.LocalDate selectedDate)` setSelectedDateWithoutShowing, This sets a date that will be marked as "selected" in the calendar.
`void` `setSettings​(DatePickerSettings datePickerSettings)` setSettings, This will set the settings instance for this calendar panel.

### 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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, setEnabled, 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, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### CalendarPanel

    public CalendarPanel()

Constructor, Independent CalendarPanel with default settings. This creates an independent calendar panel with a default set of DatePickerSettings. The calendar panel will use the default operating system locale and language.

#### CalendarPanel

    public CalendarPanel​(DatePickerSettings settings)

Constructor, Independent CalendarPanel with supplied settings. This creates This creates an independent calendar panel with the supplied date picker settings. If the datePickerSettings are null, then a default settings instance will be created and applied to the CalendarPanel.

#### CalendarPanel

    public CalendarPanel​(DatePicker parentDatePicker)

Constructor, Private CalendarPanel For DatePicker. Important Note: This function is only intended to be called from the DatePicker class. This creates a calendar panel from an existing DatePicker, for internal usage by that DatePicker instance. This will use the settings from the DatePicker instance. Technical note: This constructor is only called from the DatePicker.openPopup() function. A new CalendarPanel is created every time the popup is opened. Therefore, any DatePickerSettings variables that are initialized in this constructor are automatically able to correctly handle being set either before or after, a DatePicker is constructed.

### Method Detail

#### addCalendarSelectionListener

    public void addCalendarSelectionListener​(CalendarSelectionListener listener)

addCalendarSelectionListener, This adds a calendar selection listener to this calendar panel. For additional details, see the CalendarSelectionListener class documentation.

#### drawCalendar

    public void drawCalendar()

drawCalendar, This can be called to redraw the calendar. The calendar will be drawn with the currently displayed year and month. This function should not normally need to be called by the programmer, because the calendar will automatically redraw itself as needed.

#### getCalendarSelectionListeners

    public java.util.ArrayList<CalendarSelectionListener> getCalendarSelectionListeners()

getCalendarSelectionListeners, This returns a new ArrayList, that contains any calendar selection listeners that are registered with this CalendarPanel.

#### getSelectedDate

    public java.time.LocalDate getSelectedDate()

getSelectedDate, This returns the date that is currently marked as "selected" in the calendar. If no date is selected, then this will return null. This should not be confused with the "last valid date" of a DatePicker object. This function would typically only be needed when the CalendarPanel class is being used independently from the DatePicker class.

#### getSettings

    public DatePickerSettings getSettings()

getSettings, This returns the calendar panel settings instance.

#### removeCalendarSelectionListener

    public void removeCalendarSelectionListener​(CalendarSelectionListener listener)

removeCalendarSelectionListener, This removes the specified calendar selection listener from this CalendarPanel.

#### setSelectedDate

    public void setSelectedDate​(java.time.LocalDate selectedDate)

setSelectedDate, This sets a date that will be marked as "selected" in the calendar, and sets the displayed YearMonth to show that date. If the supplied date is null, then the selected date will be cleared, and the displayed YearMonth will be set to today's year and month. Technical note: This is implemented with the following two functions: setSelectedDateWithoutShowing() and setSelectedYearMonth().

#### setSelectedDateWithoutShowing

    public void setSelectedDateWithoutShowing​(java.time.LocalDate selectedDate)

setSelectedDateWithoutShowing, This sets a date that will be marked as "selected" in the calendar. The selectedDate will only be visible when the matching YearMonth is being displayed in the calendar. Note that this function does -not- change the currently displayed YearMonth. (This function does not "show" the YearMonth for the supplied date.)

#### setDisplayedYearMonth

    public void setDisplayedYearMonth​(java.time.YearMonth yearMonth)

setDisplayedYearMonth, This sets the year and month that is currently displayed in the calendar. The yearMonth can not be set to null. If the parameter is null, an exception will be thrown. Note that this function does -not- change the displayed selected date.

#### setLocale

    public void setLocale​(java.util.Locale locale)

setLocale, The locale for a CalendarPanel should generally be set in the DatePickerSettings. This function only exists to avoid confusion with the swing function Component.setLocale(). This forwards any function calls to: CalendarPanel.getSettings().setLocale(). For the complete Javadocs, see DatePickerSettings.setLocale().

Overrides:
  `setLocale` in class `java.awt.Component`

#### setSettings

    public void setSettings​(DatePickerSettings datePickerSettings)

setSettings, This will set the settings instance for this calendar panel. The previous settings will be deleted. Note that calling this function effectively re-initializes the picker component. All aspects of the component will be changed to match the provided settings. Any currently selected date will not be changed by this function.

#### getPreviousYearButton

    public javax.swing.JButton getPreviousYearButton()

#### getPreviousMonthButton

    public javax.swing.JButton getPreviousMonthButton()

#### getNextMonthButton

    public javax.swing.JButton getNextMonthButton()

#### getNextYearButton

    public javax.swing.JButton getNextYearButton()