Package rma.swing

Class DateChooser

All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class DateChooser extends JPanel implements ActionListener
This class represents a date chooser. The chooser allows an arbitrary date to be selected by presenting a calendar with day, month and year selectors. The range of selectable dates may be constrained by supplying a minimum and/or maximum selectable date. The date chooser is fully locale-aware.

An example DateChooser.

See Also:
  • Constructor Details

    • DateChooser

      public DateChooser()
      Construct a new DateChooser. The selection will be initialized to the current date.
    • DateChooser

      public DateChooser(Calendar date)
      Construct a new DateChooser with the specified selected date.
      Parameters:
      date - The date for the selection.
  • Method Details

    • getSelectedDate

      public Calendar getSelectedDate()
      Get a copy of the Calendar object that represents the currently selected date.
      Returns:
      The currently selected date.
    • setSelectedDate

      public void setSelectedDate(Calendar date)
      Set the selected date for the chooser.
      Parameters:
      date - The date to select.
    • setMinimumDate

      public void setMinimumDate(Calendar date)
      Set the earliest selectable date for the chooser.
      Parameters:
      date - The (possibly null) minimum selectable date.
    • getMinimumDate

      public Calendar getMinimumDate()
      Get the earliest selectable date for the chooser.
      Returns:
      The minimum selectable date, or null if there is no minimum date currently set.
    • setMaximumDate

      public void setMaximumDate(Calendar date)
      Set the latest selectable date for the chooser.
      Parameters:
      date - The (possibly null) maximum selectable date.
    • getMaximumDate

      public Calendar getMaximumDate()
      Get the latest selectable date for the chooser.
      Returns:
      The maximum selectable date, or null if there is no maximum date currently set.
    • setDateFormat

      public void setDateFormat(SimpleDateFormat format)
      Set the format for the textual date display at the bottom of the component.
      Parameters:
      format - The new date format to use.
    • actionPerformed

      public void actionPerformed(ActionEvent evt)
      Handle events. This method is public as an implementation side-effect.
      Specified by:
      actionPerformed in interface ActionListener
    • isLeapYear

      public static boolean isLeapYear(int year)
      Determine if a year is a leap year.
      Parameters:
      year - The year to check.
      Returns:
      true if the year is a leap year, and false otherwise.
    • addActionListener

      public void addActionListener(ActionListener listener)
      Add a ActionListener to this component's list of listeners.
      Parameters:
      listener - The listener to add.
    • removeActionListener

      public void removeActionListener(ActionListener listener)
      Remove a ActionListener from this component's list of listeners.
      Parameters:
      listener - The listener to remove.
    • setHighlightColor

      public void setHighlightColor(Color color)
      Set the highlight color for this component.
      Parameters:
      color - The new highlight color.
    • getHighlightColor

      public Color getHighlightColor()
      Get the highlight color for this component.
      Returns:
      The current highlight color.