Class JDatePanel

    • Nested Class Summary

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

        javax.swing.JPanel.AccessibleJPanel
      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • 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 
      Modifier and Type Field Description
      static int APRIL
      APRIL month.
      static int AUGUST
      AUGUST month.
      static int DECEMBER
      DECEMBER month.
      static int FEBRUARY
      FEBRUARY month.
      protected javax.swing.event.EventListenerList idListenerList  
      static int JANUARY
      JANUARY month.
      static int JULY
      JULY month.
      static int JUNE
      JUNE month.
      static int MARCH
      MARCH month.
      static int MAY
      MAY month.
      static int NOVEMBER
      NOVEMBER month.
      static int OCTOBER
      OCTOBER month.
      static int SEPTEMBER
      SEPTEMBER month.
      • Fields inherited from class javax.swing.JComponent

        listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
      • Fields inherited from class java.awt.Component

        accessibleContext, 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
    • Constructor Summary

      Constructors 
      Constructor Description
      JDatePanel()
      Construct a new default date panel.
      JDatePanel​(java.util.Date date)
      Construct a new date panel attached to the given date.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addChangeListener​(javax.swing.event.ChangeListener l)
      Add a ChangeListener to this panel.
      protected void fireChangeEvent()
      Fire a change event to all the registered ChangeListener
      java.util.Date getDate()
      Get the date attached to this panel
      int getDay()
      Get the day of the date.
      int getHour()
      Get the hour of the date
      int getMinute()
      Get the minute of the hour (0 - 59) specified by the current date
      int getMonth()
      Get the month of the date.
      int getYear()
      Return the year of the date.
      protected void initGUI()
      Init the GUI
      boolean isBisextile​(int year)
      Compute if the given year if a bisextile year.
      void removeChangeListener​(javax.swing.event.ChangeListener l)
      Remove the given ChangeListener from the panel.
      void setDate​(java.util.Date newDate)
      Set the date attached to this panel
      void setDay​(int day)
      Set the day of the date.
      void setHour​(int hour)
      Set the hour of the date.
      void setMinute​(int minute)
      Set the minute of the hour (0 - 59) specified by the current date
      void setMonth​(int month)
      Set the month of the date.
      void setYear​(int year)
      Set the year of the date.
      protected void updateGUI()
      Update the panel graphical components.
      • Methods inherited from class javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
      • Methods inherited from class 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, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
      • Methods inherited from class 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
      • Methods inherited from class 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, isEnabled, 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, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • JANUARY

        public static final int JANUARY
        JANUARY month. This variable is a convenience variable that match the java.util.Calendar.JANUARY variable.
        See Also:
        Constant Field Values
      • FEBRUARY

        public static final int FEBRUARY
        FEBRUARY month. This variable is a convenience variable that match the java.util.Calendar.FEBRUARY variable.
        See Also:
        Constant Field Values
      • MARCH

        public static final int MARCH
        MARCH month. This variable is a convenience variable that match the java.util.Calendar.MARCH variable.
        See Also:
        Constant Field Values
      • APRIL

        public static final int APRIL
        APRIL month. This variable is a convenience variable that match the java.util.Calendar.APRIL variable.
        See Also:
        Constant Field Values
      • MAY

        public static final int MAY
        MAY month. This variable is a convenience variable that match the java.util.Calendar.MAY variable.
        See Also:
        Constant Field Values
      • JUNE

        public static final int JUNE
        JUNE month. This variable is a convenience variable that match the java.util.Calendar.JUNE variable.
        See Also:
        Constant Field Values
      • JULY

        public static final int JULY
        JULY month. This variable is a convenience variable that match the java.util.Calendar.JULY variable.
        See Also:
        Constant Field Values
      • AUGUST

        public static final int AUGUST
        AUGUST month. This variable is a convenience variable that match the java.util.Calendar.AUGUST variable.
        See Also:
        Constant Field Values
      • SEPTEMBER

        public static final int SEPTEMBER
        SEPTEMBER month. This variable is a convenience variable that match the java.util.Calendar.SEPTEMBER variable.
        See Also:
        Constant Field Values
      • OCTOBER

        public static final int OCTOBER
        OCTOBER month. This variable is a convenience variable that match the java.util.Calendar.OCTOBER variable.
        See Also:
        Constant Field Values
      • NOVEMBER

        public static final int NOVEMBER
        NOVEMBER month. This variable is a convenience variable that match the java.util.Calendar.NOVEMBER variable.
        See Also:
        Constant Field Values
      • DECEMBER

        public static final int DECEMBER
        DECEMBER month. This variable is a convenience variable that match the java.util.Calendar.DECEMBER variable.
        See Also:
        Constant Field Values
      • idListenerList

        protected javax.swing.event.EventListenerList idListenerList
    • Constructor Detail

      • JDatePanel

        public JDatePanel()
        Construct a new default date panel. The date is set by default to the current date
      • JDatePanel

        public JDatePanel​(java.util.Date date)
        Construct a new date panel attached to the given date.
        Parameters:
        date - the date to edit within the panel.
    • Method Detail

      • initGUI

        protected void initGUI()
        Init the GUI
      • updateGUI

        protected void updateGUI()
        Update the panel graphical components. The components shows the current date.
        See Also:
        setDate(Date), getDate()
      • getDate

        public java.util.Date getDate()
        Get the date attached to this panel
        Returns:
        the java object representing the date attached to this panel.
        See Also:
        setDate(Date)
      • setDate

        public void setDate​(java.util.Date newDate)
        Set the date attached to this panel
        Parameters:
        newDate - the java object representing the date to attach to this panel.
        See Also:
        getDate()
      • getMinute

        public int getMinute()
        Get the minute of the hour (0 - 59) specified by the current date
        Returns:
        the minute in the hour.
        See Also:
        setMinute(int)
      • setMinute

        public void setMinute​(int minute)
        Set the minute of the hour (0 - 59) specified by the current date
        Parameters:
        minute - the minute in the hour.
        See Also:
        getMinute()
      • getHour

        public int getHour()
        Get the hour of the date
        Returns:
        the hour of the day (0 - 24)
        See Also:
        setHour(int)
      • setHour

        public void setHour​(int hour)
        Set the hour of the date.
        Parameters:
        hour - the hour of the day (0 - 24)
        See Also:
        getHour()
      • getMonth

        public int getMonth()
        Get the month of the date.
        Returns:
        the month of the date as stated in Calendar class
        See Also:
        setMonth(int)
      • setMonth

        public void setMonth​(int month)
        Set the month of the date. The month is given by the variable available in the class. If the day is not compatible with the given month, day is changed to match the new month.
        Parameters:
        month - the month.
        See Also:
        getMonth()
      • getDay

        public int getDay()
        Get the day of the date. The day number if the day in the month.
        Returns:
        int the day of the date (month relative).
        See Also:
        setDay(int)
      • setDay

        public void setDay​(int day)
        Set the day of the date. If the day does not fit the month and the year, it is changed to fit.
        Parameters:
        day - the day of the date
        See Also:
        getDay()
      • getYear

        public int getYear()
        Return the year of the date.
        Returns:
        the year of the date.
        See Also:
        setYear(int)
      • setYear

        public void setYear​(int year)
        Set the year of the date. A year has to be positive.
        Parameters:
        year - the year of the date.
        See Also:
        getYear()
      • isBisextile

        public boolean isBisextile​(int year)
        Compute if the given year if a bisextile year. A year is bisextile if it can be divided by 400 or if it can be divided by 4 but not by 100 at the same time.
        Parameters:
        year - the year to check
        Returns:
        true if the year is bisextile, false otherwise.
      • addChangeListener

        public void addChangeListener​(javax.swing.event.ChangeListener l)
        Add a ChangeListener to this panel.
        Parameters:
        l - the listener to attach to this panel
        See Also:
        removeChangeListener(ChangeListener)
      • removeChangeListener

        public void removeChangeListener​(javax.swing.event.ChangeListener l)
        Remove the given ChangeListener from the panel.
        Parameters:
        l - the listener to detach from the panel.
        See Also:
        addChangeListener(ChangeListener)