Class CalendarPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class CalendarPanel extends 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:
  • Constructor Details

    • 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 Details

    • 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 ArrayList<CalendarSelectionListener> getCalendarSelectionListeners()
      getCalendarSelectionListeners, This returns a new ArrayList, that contains any calendar selection listeners that are registered with this CalendarPanel.
    • getSelectedDate

      public 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(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(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(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(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 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 JButton getPreviousYearButton()
    • getPreviousMonthButton

      public JButton getPreviousMonthButton()
    • getNextMonthButton

      public JButton getNextMonthButton()
    • getNextYearButton

      public JButton getNextYearButton()