Class Date_selector_dialog

  • All Implemented Interfaces:
    Date_selector, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.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:
    Popup_dialog, Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JDialog

        javax.swing.JDialog.AccessibleJDialog
      • Nested classes/interfaces inherited from class java.awt.Dialog

        java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
      • Nested classes/interfaces inherited from class java.awt.Window

        java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
      • 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.JDialog

        accessibleContext, rootPane, rootPaneCheckingEnabled
      • Fields inherited from class java.awt.Dialog

        DEFAULT_MODALITY_TYPE
      • Fields inherited from class java.awt.Component

        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
      • Fields inherited from interface javax.swing.WindowConstants

        DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addActionListener​(java.awt.event.ActionListener l)
      Add an action listner for both Date_selector.CHANGE_ACTION and Date_selector.SELECT_ACTION action events.
      int get​(int f)
      Must work just like Calendar.get(int)
      java.util.Date get_current_date()
      Get the current date.
      java.util.Date get_selected_date()
      For use when you pop up a dialog using setVisible(true) rather than select().
      int getCloseAction()  
      javax.swing.JComponent getComponent()  
      Date_selector getInnerSelector()  
      void removeActionListener​(java.awt.event.ActionListener l)
      Remove a previously-added listener
      void roll​(int f, boolean up)
      Must work just like Calendar.roll(int, boolean)
      java.util.Date select()
      Pops up the chooser and blocks until the user selects a date.
      void set_selected_date​(java.util.Date d)  
      void setCloseAction​(int i)
      The close action to set.
      • Methods inherited from class javax.swing.JDialog

        addImpl, createRootPane, dialogInit, getAccessibleContext, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
      • Methods inherited from class java.awt.Dialog

        addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, setVisible, show, toBack
      • Methods inherited from class java.awt.Window

        addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFront
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, 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

      • Date_selector_dialog

        public Date_selector_dialog​(java.awt.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​(java.awt.Dialog parent)
      • Date_selector_dialog

        public Date_selector_dialog​(java.awt.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.
    • Method Detail

      • get_selected_date

        public java.util.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 java.util.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.
      • removeActionListener

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

        public java.util.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