- 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
public class JDatePanel extends JPanel
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:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description static intAPRILAPRIL month.static intAUGUSTAUGUST month.static intDECEMBERDECEMBER month.static intFEBRUARYFEBRUARY month.protected EventListenerListidListenerListThe attached listeners.static intJANUARYJANUARY month.static intJULYJULY month.static intJUNEJUNE month.static intMARCHMARCH month.static intMAYMAY month.static intNOVEMBERNOVEMBER month.static intOCTOBEROCTOBER month.static intSEPTEMBERSEPTEMBER 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(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 voidaddChangeListener(ChangeListener l)Add aChangeListenerto this panel.protected voidfireChangeEvent()Fire a change event to all the registeredChangeListenerDategetDate()Get the date attached to this panelintgetDay()Get the day of the date.intgetHour()Get the hour of the dateintgetMinute()Get 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.voidremoveChangeListener(ChangeListener l)Remove the givenChangeListenerfrom the panel.voidsetDate(Date newDate)Set 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 voidupdateGUI()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
-
-
-
-
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 EventListenerList idListenerList
The attached listeners.
-
-
Constructor Detail
-
JDatePanel
public JDatePanel()
Construct a new default date panel. The date is set by default to the current date
-
JDatePanel
public JDatePanel(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 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(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:
trueif the year is bisextile,falseotherwise.
-
addChangeListener
public void addChangeListener(ChangeListener l)
Add aChangeListenerto this panel.- Parameters:
l- the listener to attach to this panel- See Also:
removeChangeListener(ChangeListener)
-
removeChangeListener
public void removeChangeListener(ChangeListener l)
Remove the givenChangeListenerfrom the panel.- Parameters:
l- the listener to detach from the panel.- See Also:
addChangeListener(ChangeListener)
-
fireChangeEvent
protected void fireChangeEvent()
Fire a change event to all the registeredChangeListener
-
-