java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.jorigin.swing.JDatePanel
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible
A Simple component used to handle date display and modification.
- Since:
- 1.0.0
- Version:
- "1.0.14" - b202111241200L
- Author:
- Julien SEINTURIER - Université de Toulon / CNRS LIS umr 7020 - github.com/jorigin/jcommon (contact@jorigin.org)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAPRIL month.static final intAUGUST month.static final intDECEMBER month.static final intFEBRUARY month.protected EventListenerListThe attached listeners.static final intJANUARY month.static final intJULY month.static final intJUNE month.static final intMARCH month.static final intMAY month.static final intNOVEMBER month.static final intOCTOBER month.static final intSEPTEMBER 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_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new default date panel.JDatePanel(Date date) Construct a new date panel attached to the given date. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd aChangeListenerto this panel.protected voidFire a change event to all the registeredChangeListenergetDate()Get the date attached to this panelintgetDay()Get the day of the date.intgetHour()Get the hour of the dateintGet the minute of the hour (0 - 59) specified by the current dateintgetMonth()Get the month of the date.intgetYear()Return the year of the date.protected voidinitGUI()Init the GUIbooleanisBisextile(int year) Compute if the given year if a bisextile year.voidRemove the givenChangeListenerfrom the panel.voidSet the date attached to this panelvoidsetDay(int day) Set the day of the date.voidsetHour(int hour) Set the hour of the date.voidsetMinute(int minute) Set the minute of the hour (0 - 59) specified by the current datevoidsetMonth(int month) Set the month of the date.voidsetYear(int year) Set the year of the date.protected voidUpdate the panel graphical components.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods 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, updateMethods 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, validateTreeMethods 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
-
Field Details
-
JANUARY
public static final int JANUARYJANUARY month. This variable is a convenience variable that match the java.util.Calendar.JANUARY variable.- See Also:
-
FEBRUARY
public static final int FEBRUARYFEBRUARY month. This variable is a convenience variable that match the java.util.Calendar.FEBRUARY variable.- See Also:
-
MARCH
public static final int MARCHMARCH month. This variable is a convenience variable that match the java.util.Calendar.MARCH variable.- See Also:
-
APRIL
public static final int APRILAPRIL month. This variable is a convenience variable that match the java.util.Calendar.APRIL variable.- See Also:
-
MAY
public static final int MAYMAY month. This variable is a convenience variable that match the java.util.Calendar.MAY variable.- See Also:
-
JUNE
public static final int JUNEJUNE month. This variable is a convenience variable that match the java.util.Calendar.JUNE variable.- See Also:
-
JULY
public static final int JULYJULY month. This variable is a convenience variable that match the java.util.Calendar.JULY variable.- See Also:
-
AUGUST
public static final int AUGUSTAUGUST month. This variable is a convenience variable that match the java.util.Calendar.AUGUST variable.- See Also:
-
SEPTEMBER
public static final int SEPTEMBERSEPTEMBER month. This variable is a convenience variable that match the java.util.Calendar.SEPTEMBER variable.- See Also:
-
OCTOBER
public static final int OCTOBEROCTOBER month. This variable is a convenience variable that match the java.util.Calendar.OCTOBER variable.- See Also:
-
NOVEMBER
public static final int NOVEMBERNOVEMBER month. This variable is a convenience variable that match the java.util.Calendar.NOVEMBER variable.- See Also:
-
DECEMBER
public static final int DECEMBERDECEMBER month. This variable is a convenience variable that match the java.util.Calendar.DECEMBER variable.- See Also:
-
idListenerList
The attached listeners.
-
-
Constructor Details
-
JDatePanel
public JDatePanel()Construct a new default date panel. The date is set by default to the current date -
JDatePanel
Construct a new date panel attached to the given date.- Parameters:
date- the date to edit within the panel.
-
-
Method Details
-
initGUI
protected void initGUI()Init the GUI -
updateGUI
protected void updateGUI()Update the panel graphical components. The components shows the current date.- See Also:
-
getDate
Get the date attached to this panel- Returns:
- the java object representing the date attached to this panel.
- See Also:
-
setDate
Set the date attached to this panel- Parameters:
newDate- the java object representing the date to attach to this panel.- See Also:
-
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
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:
-
getHour
public int getHour()Get the hour of the date- Returns:
- the hour of the day (0 - 24)
- See Also:
-
setHour
public void setHour(int hour) Set the hour of the date.- Parameters:
hour- the hour of the day (0 - 24)- See Also:
-
getMonth
public int getMonth()Get the month of the date.- Returns:
- the month of the date as stated in Calendar class
- See Also:
-
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:
-
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
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:
-
getYear
public int getYear()Return the year of the date.- Returns:
- the year of the date.
- See Also:
-
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:
-
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:
trueif the year is bisextile,falseotherwise.
-
addChangeListener
Add aChangeListenerto this panel.- Parameters:
l- the listener to attach to this panel- See Also:
-
removeChangeListener
Remove the givenChangeListenerfrom the panel.- Parameters:
l- the listener to detach from the panel.- See Also:
-
fireChangeEvent
protected void fireChangeEvent()Fire a change event to all the registeredChangeListener- See Also:
-