类 JDateChooser

  • 所有已实现的接口:
    java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

    public class JDateChooser
    extends javax.swing.JPanel
    implements java.awt.event.ActionListener, java.beans.PropertyChangeListener
    A date chooser containing a date editor and a button, that makes a JCalendar visible for choosing a date. If no date editor is specified, a JTextFieldDateEditor is used as default.
    版本:
    $LastChangedRevision: 149 $, $LastChangedDate: 2011-06-07 19:05:02 +0200 (Di, 07 Jun 2011) $
    作者:
    Kai Toedter
    另请参阅:
    序列化表格
    • 嵌套类概要

      • 从类继承的嵌套类/接口 javax.swing.JPanel

        javax.swing.JPanel.AccessibleJPanel
      • 从类继承的嵌套类/接口 javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • 从类继承的嵌套类/接口 java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • 从类继承的嵌套类/接口 java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • 字段概要

      字段 
      修饰符和类型 字段 说明
      protected javax.swing.JButton calendarButton  
      protected IDateEditor dateEditor  
      protected boolean dateSelected  
      protected boolean isInitialized  
      protected JCalendar jcalendar  
      protected java.util.Date lastSelectedDate  
      protected javax.swing.JPopupMenu popup  
      • 从类继承的字段 javax.swing.JComponent

        listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
      • 从类继承的字段 java.awt.Component

        accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • 从接口继承的字段 java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • 构造器概要

      构造器 
      构造器 说明
      JDateChooser()
      Creates a new JDateChooser.
      JDateChooser​(java.lang.String datePattern, java.lang.String maskPattern, char placeholder)
      Creates a new JDateChooser.
      JDateChooser​(java.util.Date date)
      Creates a new JDateChooser.
      JDateChooser​(java.util.Date date, java.lang.String dateFormatString)
      Creates a new JDateChooser.
      JDateChooser​(java.util.Date date, java.lang.String dateFormatString, IDateEditor dateEditor)
      Creates a new JDateChooser.
      JDateChooser​(IDateEditor dateEditor)
      Creates a new JDateChooser with given IDateEditor.
      JDateChooser​(JCalendar jcal, java.util.Date date, java.lang.String dateFormatString, IDateEditor dateEditor)
      Creates a new JDateChooser.
    • 方法概要

      所有方法 静态方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      void actionPerformed​(java.awt.event.ActionEvent e)
      Called when the calendar button was pressed.
      void cleanup()
      Should only be invoked if the JDateChooser is not used anymore.
      java.util.Calendar getCalendar()
      Returns the calendar.
      javax.swing.JButton getCalendarButton()
      Returns the calendar button.
      java.util.Date getDate()
      Returns the date.
      IDateEditor getDateEditor()
      Returns the date editor.
      java.lang.String getDateFormatString()
      Gets the date format string.
      JCalendar getJCalendar()
      Returns the JCalendar component.
      java.util.Date getMaxSelectableDate()
      Gets the maximum selectable date.
      java.util.Date getMinSelectableDate()
      Gets the minimum selectable date.
      boolean isEnabled()
      Returns true, if enabled.
      static void main​(java.lang.String[] s)
      Creates a JFrame with a JDateChooser inside and can be used for testing.
      void propertyChange​(java.beans.PropertyChangeEvent evt)
      Listens for a "date" property change or a "day" property change event from the JCalendar.
      boolean requestFocusInWindow()  
      void setCalendar​(java.util.Calendar calendar)
      Sets the calendar.
      void setDate​(java.util.Date date)
      Sets the date.
      void setDateFormatString​(java.lang.String dfString)
      Sets the date format string.
      void setEnabled​(boolean enabled)
      Enable or disable the JDateChooser.
      void setFont​(java.awt.Font font)
      Sets the font of all subcomponents.
      void setIcon​(javax.swing.ImageIcon icon)
      Sets the icon of the buuton.
      void setLocale​(java.util.Locale l)
      Sets the locale.
      void setMaxSelectableDate​(java.util.Date max)  
      void setMinSelectableDate​(java.util.Date min)  
      void setSelectableDateRange​(java.util.Date min, java.util.Date max)
      Sets a valid date range for selectable dates.
      void updateUI()
      Updates the UI of itself and the popup.
      • 从类继承的方法 javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, paramString, setUI
      • 从类继承的方法 javax.swing.JComponent

        addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
      • 从类继承的方法 java.awt.Container

        add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
      • 从类继承的方法 java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 字段详细资料

      • calendarButton

        protected javax.swing.JButton calendarButton
      • popup

        protected javax.swing.JPopupMenu popup
      • isInitialized

        protected boolean isInitialized
      • dateSelected

        protected boolean dateSelected
      • lastSelectedDate

        protected java.util.Date lastSelectedDate
    • 构造器详细资料

      • JDateChooser

        public JDateChooser()
        Creates a new JDateChooser. By default, no date is set and the textfield is empty.
      • JDateChooser

        public JDateChooser​(IDateEditor dateEditor)
        Creates a new JDateChooser with given IDateEditor.
        参数:
        dateEditor - the dateEditor to be used used to display the date. if null, a JTextFieldDateEditor is used.
      • JDateChooser

        public JDateChooser​(java.util.Date date)
        Creates a new JDateChooser.
        参数:
        date - the date or null
      • JDateChooser

        public JDateChooser​(java.util.Date date,
                            java.lang.String dateFormatString)
        Creates a new JDateChooser.
        参数:
        date - the date or null
        dateFormatString - the date format string or null (then MEDIUM SimpleDateFormat format is used)
      • JDateChooser

        public JDateChooser​(java.util.Date date,
                            java.lang.String dateFormatString,
                            IDateEditor dateEditor)
        Creates a new JDateChooser.
        参数:
        date - the date or null
        dateFormatString - the date format string or null (then MEDIUM SimpleDateFormat format is used)
        dateEditor - the dateEditor to be used used to display the date. if null, a JTextFieldDateEditor is used.
      • JDateChooser

        public JDateChooser​(java.lang.String datePattern,
                            java.lang.String maskPattern,
                            char placeholder)
        Creates a new JDateChooser. If the JDateChooser is created with this constructor, the mask will be always visible in the date editor. Please note that the date pattern and the mask will not be changed if the locale of the JDateChooser is changed.
        参数:
        datePattern - the date pattern, e.g. "MM/dd/yy"
        maskPattern - the mask pattern, e.g. "##/##/##"
        placeholder - the place holder character, e.g. '_'
      • JDateChooser

        public JDateChooser​(JCalendar jcal,
                            java.util.Date date,
                            java.lang.String dateFormatString,
                            IDateEditor dateEditor)
        Creates a new JDateChooser.
        参数:
        jcal - the JCalendar to be used
        date - the date or null
        dateFormatString - the date format string or null (then MEDIUM Date format is used)
        dateEditor - the dateEditor to be used used to display the date. if null, a JTextFieldDateEditor is used.
    • 方法详细资料

      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Called when the calendar button was pressed.
        指定者:
        actionPerformed 在接口中 java.awt.event.ActionListener
        参数:
        e - the action event
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent evt)
        Listens for a "date" property change or a "day" property change event from the JCalendar. Updates the date editor and closes the popup.
        指定者:
        propertyChange 在接口中 java.beans.PropertyChangeListener
        参数:
        evt - the event
      • updateUI

        public void updateUI()
        Updates the UI of itself and the popup.
        覆盖:
        updateUI 在类中 javax.swing.JPanel
      • setLocale

        public void setLocale​(java.util.Locale l)
        Sets the locale.
        覆盖:
        setLocale 在类中 java.awt.Component
        参数:
        l - The new locale value
      • getDateFormatString

        public java.lang.String getDateFormatString()
        Gets the date format string.
        返回:
        Returns the dateFormatString.
      • setDateFormatString

        public void setDateFormatString​(java.lang.String dfString)
        Sets the date format string. E.g "MMMMM d, yyyy" will result in "July 21, 2004" if this is the selected date and locale is English.
        参数:
        dfString - The dateFormatString to set.
      • getDate

        public java.util.Date getDate()
        Returns the date. If the JDateChooser is started with a null date and no date was set by the user, null is returned.
        返回:
        the current date
      • setDate

        public void setDate​(java.util.Date date)
        Sets the date. Fires the property change "date" if date != null.
        参数:
        date - the new date.
      • getCalendar

        public java.util.Calendar getCalendar()
        Returns the calendar. If the JDateChooser is started with a null date (or null calendar) and no date was set by the user, null is returned.
        返回:
        the current calendar
      • setCalendar

        public void setCalendar​(java.util.Calendar calendar)
        Sets the calendar. Value null will set the null date on the date editor.
        参数:
        calendar - the calendar.
      • setEnabled

        public void setEnabled​(boolean enabled)
        Enable or disable the JDateChooser.
        覆盖:
        setEnabled 在类中 javax.swing.JComponent
        参数:
        enabled - the new enabled value
      • isEnabled

        public boolean isEnabled()
        Returns true, if enabled.
        覆盖:
        isEnabled 在类中 java.awt.Component
        返回:
        true, if enabled.
      • setIcon

        public void setIcon​(javax.swing.ImageIcon icon)
        Sets the icon of the buuton.
        参数:
        icon - The new icon
      • setFont

        public void setFont​(java.awt.Font font)
        Sets the font of all subcomponents.
        覆盖:
        setFont 在类中 javax.swing.JComponent
        参数:
        font - the new font
      • getJCalendar

        public JCalendar getJCalendar()
        Returns the JCalendar component. THis is usefull if you want to set some properties.
        返回:
        the JCalendar
      • getCalendarButton

        public javax.swing.JButton getCalendarButton()
        Returns the calendar button.
        返回:
        the calendar button
      • getDateEditor

        public IDateEditor getDateEditor()
        Returns the date editor.
        返回:
        the date editor
      • setSelectableDateRange

        public void setSelectableDateRange​(java.util.Date min,
                                           java.util.Date max)
        Sets a valid date range for selectable dates. If max is before min, the default range with no limitation is set.
        参数:
        min - the minimum selectable date or null (then the minimum date is set to 01\01\0001)
        max - the maximum selectable date or null (then the maximum date is set to 01\01\9999)
      • setMaxSelectableDate

        public void setMaxSelectableDate​(java.util.Date max)
      • setMinSelectableDate

        public void setMinSelectableDate​(java.util.Date min)
      • getMaxSelectableDate

        public java.util.Date getMaxSelectableDate()
        Gets the maximum selectable date.
        返回:
        the maximum selectable date
      • getMinSelectableDate

        public java.util.Date getMinSelectableDate()
        Gets the minimum selectable date.
        返回:
        the minimum selectable date
      • cleanup

        public void cleanup()
        Should only be invoked if the JDateChooser is not used anymore. Due to popup handling it had to register a change listener to the default menu selection manager which will be unregistered here. Use this method to cleanup possible memory leaks.
      • requestFocusInWindow

        public boolean requestFocusInWindow()
        覆盖:
        requestFocusInWindow 在类中 javax.swing.JComponent
      • main

        public static void main​(java.lang.String[] s)
        Creates a JFrame with a JDateChooser inside and can be used for testing.
        参数:
        s - The command line arguments