Class DateChooser

All Implemented Interfaces:
ActionListener, FocusListener, ItemListener, KeyListener, MouseListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class DateChooser extends IrisDialog implements ItemListener, MouseListener, FocusListener, KeyListener, ActionListener
Custom dialog box to enter dates. The DateChooser class presents a calendar and allows the user to visually select a day, month and year so that it is impossible to enter an invalid date.
See Also:
  • Constructor Details

    • DateChooser

      public DateChooser(Dialog owner, String title)
      Constructs a new DateChooser with the given title.
      Parameters:
      owner - owner dialog
      title - dialog title
    • DateChooser

      public DateChooser(Dialog owner)
      Constructs a new DateChooser.
      Parameters:
      owner - owner dialog
    • DateChooser

      public DateChooser(Frame owner, String title)
      Constructs a new DateChooser with the given title.
      Parameters:
      owner - owner frame
      title - dialog title
    • DateChooser

      public DateChooser(Frame owner)
      Constructs a new DateChooser.
      Parameters:
      owner - owner frame
  • Method Details

    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Called when the "Ok" button is pressed. Just sets a flag and hides the dialog box.
      Specified by:
      actionPerformed in interface ActionListener
    • focusGained

      public void focusGained(FocusEvent e)
      Called when the calendar gains the focus. Just re-sets the selected day so that it is redrawn with the border that indicate focus.
      Specified by:
      focusGained in interface FocusListener
    • focusLost

      public void focusLost(FocusEvent e)
      Called when the calendar loses the focus. Just re-sets the selected day so that it is redrawn without the border that indicate focus.
      Specified by:
      focusLost in interface FocusListener
    • itemStateChanged

      public void itemStateChanged(ItemEvent e)
      Called when a new month or year is selected. Updates the calendar to reflect the selection.
      Specified by:
      itemStateChanged in interface ItemListener
    • keyPressed

      public void keyPressed(KeyEvent e)
      Called when a key is pressed and the calendar has the focus. Handles the arrow keys so that the user can select a day using the keyboard.
      Specified by:
      keyPressed in interface KeyListener
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Called when the mouse is clicked on a day in the calendar. Selects the clicked day.
      Specified by:
      mouseClicked in interface MouseListener
    • keyReleased

      public void keyReleased(KeyEvent e)
      Specified by:
      keyReleased in interface KeyListener
    • keyTyped

      public void keyTyped(KeyEvent e)
      Specified by:
      keyTyped in interface KeyListener
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener
    • mousePressed

      public void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • select

      public Date select(Date date)
      Selects a date. Displays the dialog box, with a given date as the selected date, and allows the user select a new date.
      Parameters:
      date - initial date
      Returns:
      the new date selected or null if the user press "Cancel" or closes the dialog box
    • select

      public Date select()
      Selects new date. Just calls select(Date) with the system date as the parameter.
      Returns:
      the same as the function select(Date)