All Implemented Interfaces:
Date_selector, ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class Date_selector_dialog extends Popup_dialog implements Date_selector
The Date_selector_dialog, shown below, combines a Date_selector and a Popup_dialog to provide a standalone, popup dialog for choosing dates.
The dialog is a free-floating top-level window. You can drag it around by the title bar and close it by clicking on the "close" icon.

The class does implement the Date_selector interface, but bear in mind that the window closes when the user selects a date. Unlike the Titled_date_selector wrapper class, both of the action events are sent to listeners, however. Create one the hard way like this:

 Date_selector calendar = new Date_selector_panel(selector);
 calendar = new Navigable_date_selector(calendar); // add navigation
 Date_selector_dialog chooser = new Date_selector_dialog(parent_frame, calendar);
 //...
 Date d = chooser.select(); // Pops up chooser; returns selected Date.
 

You can leave out the navigation bar by omitting the second line of the previous example. The following convenience constructor has exactly the same effect as the earlier code:

  Date_selector_dialog chooser = new Date_selector_dialog(parent_frame);
 <pre>
 You can also pop up the dialog like this:
 <pre>
  chooser.setVisible(true);    // blocks until dialog closed
  Date d = chooser.get_selected_date();
 </pre>
 
This class is a stand-alone dialog. For a version that you can embed into another window, see Date_selector_panel .

@see Date_selector @see Date_selector_panel @see Navigable_date_selector @see Titled_date_selector

See Also:
  • Constructor Details

    • Date_selector_dialog

      public Date_selector_dialog(Frame parent)
      Creates a dialog box with the indicated parent that holds a standard Date_selector_panel (as created using the no-arg constructor).
    • Date_selector_dialog

      public Date_selector_dialog(Dialog parent)
    • Date_selector_dialog

      public Date_selector_dialog(Frame parent, Date_selector toWrap)
      Creates a dialog box with the indicated parent that holds the indicated Date_selector. Note that the current month and year is displayed in the dialog-box title bar, so there's no need to display it in the selector too.
    • Date_selector_dialog

      public Date_selector_dialog(Dialog parent, Date_selector toWrap)
  • Method Details

    • get_selected_date

      public Date get_selected_date()
      For use when you pop up a dialog using setVisible(true) rather than select().
      Specified by:
      get_selected_date in interface Date_selector
      Returns:
      the selected date or null if the dialog was closed without selecting anything.
    • get_current_date

      public Date get_current_date()
      Get the current date. The dialog stays in existance until the user closes it or selects a date, so this method can be used to see what month the user has scrolled to.
      Specified by:
      get_current_date in interface Date_selector
      Returns:
      the date currently displayed on the calendar.
    • set_selected_date

      public void set_selected_date(Date d)
      Specified by:
      set_selected_date in interface Date_selector
    • addActionListener

      public void addActionListener(ActionListener l)
      Add an action listner for both Date_selector.CHANGE_ACTION and Date_selector.SELECT_ACTION action events.
      Specified by:
      addActionListener in interface Date_selector
    • removeActionListener

      public void removeActionListener(ActionListener l)
      Remove a previously-added listener
      Specified by:
      removeActionListener in interface Date_selector
    • select

      public Date select()
      Pops up the chooser and blocks until the user selects a date.
      Returns:
      the selected date or null if the dialog was closed without selecting anything.
    • roll

      public void roll(int f, boolean up)
      Description copied from interface: Date_selector
      Must work just like Calendar.roll(int, boolean)
      Specified by:
      roll in interface Date_selector
    • get

      public int get(int f)
      Description copied from interface: Date_selector
      Must work just like Calendar.get(int)
      Specified by:
      get in interface Date_selector
    • getCloseAction

      public int getCloseAction()
      Returns:
      Current close action: Date_selector.CHANGE_ACTION, Date_selector.SELECT_ACTION, or Date_selector.COMMIT_ACTION
    • setCloseAction

      public void setCloseAction(int i)
      The close action to set. Allowable values are Date_selector.CHANGE_ACTION, Date_selector.SELECT_ACTION, and Date_selector.COMMIT_ACTION
    • getComponent

      public JComponent getComponent()
      Specified by:
      getComponent in interface Date_selector
    • getInnerSelector

      public Date_selector getInnerSelector()
      Specified by:
      getInnerSelector in interface Date_selector
      Returns:
      A reference to any 'inner' selector inside this Date_selector implementation. May return this.