Class JDateChooser
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.wisc.ssec.mcidasv.data.dateChooser.JDateChooser
- All Implemented Interfaces:
ActionListener
,ImageObserver
,MenuContainer
,PropertyChangeListener
,Serializable
,EventListener
,Accessible
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.
- Version:
- $LastChangedRevision: 101 $, $LastChangedDate: 2006-06-04 14:42:29 +0200 (So, 04 Jun 2006) $
- Author:
- Kai Toedter
- See Also:
-
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
FieldsModifier and TypeFieldDescriptionprotected JButton
private ChangeListener
protected IDateEditor
protected boolean
protected boolean
protected JCalendar
protected Date
private static final org.slf4j.Logger
protected JPopupMenu
private static final long
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
ConstructorsConstructorDescriptionCreates a new JDateChooser.JDateChooser
(IDateEditor dateEditor) Creates a new JDateChooser with given IDateEditor.JDateChooser
(JCalendar jcal, Date date, String dateFormatString, IDateEditor dateEditor) Creates a new JDateChooser.JDateChooser
(String datePattern, String maskPattern, char placeholder) Creates a new JDateChooser.JDateChooser
(Date date) Creates a new JDateChooser.JDateChooser
(Date date, String dateFormatString) Creates a new JDateChooser.JDateChooser
(Date date, String dateFormatString, IDateEditor dateEditor) Creates a new JDateChooser. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Called when the jalendar button was pressed.void
cleanup()
Should only be invoked if the JDateChooser is not used anymore.Returns the calendar.Returns the calendar button.getDate()
Returns the date.Returns the date editor.Gets the date format string.Returns the JCalendar component.Gets the maximum selectable date.Gets the minimum selectable date.boolean
Returns true, if enabled.static void
Creates a JFrame with a JDateChooser inside and can be used for testing.void
Listens for a "date" property change or a "day" property change event from the JCalendar.void
setCalendar
(Calendar calendar) Sets the calendar.void
Sets the date.void
setDateFormatString
(String dfString) Sets the date format string.void
setEnabled
(boolean enabled) Enable or disable the JDateChooser.void
Sets the font of all subcomponents.void
Sets the icon of the buuton.void
Sets the locale.void
setMaxSelectableDate
(Date max) void
setMinSelectableDate
(Date min) void
setSelectableDateRange
(Date min, Date max) Sets a valid date range for selectable dates.void
updateUI()
Updates the UI of itself and the popup.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI
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, setFocusTraversalKeys, 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, 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
-
Field Details
-
logger
-
serialVersionUID
- See Also:
-
dateEditor
-
calendarButton
-
jcalendar
-
popup
-
isInitialized
-
dateSelected
-
lastSelectedDate
-
changeListener
-
-
Constructor Details
-
JDateChooser
public JDateChooser()Creates a new JDateChooser. By default, no date is set and the textfield is empty. -
JDateChooser
Creates a new JDateChooser with given IDateEditor.- Parameters:
dateEditor
- the dateEditor to be used used to display the date. if null, a JTextFieldDateEditor is used.
-
JDateChooser
Creates a new JDateChooser.- Parameters:
date
- the date or null
-
JDateChooser
Creates a new JDateChooser.- Parameters:
date
- the date or nulldateFormatString
- the date format string or null (then MEDIUM SimpleDateFormat format is used)
-
JDateChooser
Creates a new JDateChooser.- Parameters:
date
- the date or nulldateFormatString
- 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
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.- Parameters:
datePattern
- the date pattern, e.g. "MM/dd/yy"maskPattern
- the mask pattern, e.g. "##/##/##"placeholder
- the placeholer charachter, e.g. '_'
-
JDateChooser
Creates a new JDateChooser.- Parameters:
jcal
- the JCalendar to be useddate
- the date or nulldateFormatString
- 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.
-
-
Method Details
-
actionPerformed
Called when the jalendar button was pressed.- Specified by:
actionPerformed
in interfaceActionListener
- Parameters:
e
- the action event
-
propertyChange
Listens for a "date" property change or a "day" property change event from the JCalendar. Updates the date editor and closes the popup.- Specified by:
propertyChange
in interfacePropertyChangeListener
- Parameters:
evt
- the event
-
updateUI
Updates the UI of itself and the popup. -
setLocale
Sets the locale. -
getJcalendar
- Returns:
- the jcalendar
-
getDateFormatString
Gets the date format string.- Returns:
- Returns the dateFormatString.
-
setDateFormatString
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.- Parameters:
dfString
- The dateFormatString to set.
-
getDate
Returns the date. If the JDateChooser is started with a null date and no date was set by the user, null is returned.- Returns:
- the current date
-
setDate
Sets the date. Fires the property change "date" if date != null.- Parameters:
date
- the new date.
-
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.- Returns:
- the current calendar
-
setCalendar
Sets the calendar. Value null will set the null date on the date editor.- Parameters:
calendar
- the calendar.
-
setEnabled
Enable or disable the JDateChooser.- Overrides:
setEnabled
in classJComponent
- Parameters:
enabled
- the new enabled value
-
isEnabled
Returns true, if enabled. -
setIcon
Sets the icon of the buuton.- Parameters:
icon
- The new icon
-
setFont
Sets the font of all subcomponents.- Overrides:
setFont
in classJComponent
- Parameters:
font
- the new font
-
getJCalendar
Returns the JCalendar component. THis is usefull if you want to set some properties.- Returns:
- the JCalendar
-
getCalendarButton
Returns the calendar button.- Returns:
- the calendar button
-
getDateEditor
Returns the date editor.- Returns:
- the date editor
-
setSelectableDateRange
Sets a valid date range for selectable dates. If max is before min, the default range with no limitation is set.- Parameters:
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
-
setMinSelectableDate
-
getMaxSelectableDate
Gets the maximum selectable date.- Returns:
- the maximum selectable date
-
getMinSelectableDate
Gets the minimum selectable date.- Returns:
- the minimum selectable date
-
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. -
main
Creates a JFrame with a JDateChooser inside and can be used for testing.- Parameters:
s
- The command line arguments
-