Package edu.wisc.ssec.mcidasv.ui
Class JCalendarDateEditor
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextField
javax.swing.JFormattedTextField
edu.wisc.ssec.mcidasv.ui.JCalendarDateEditor
- All Implemented Interfaces:
com.toedter.calendar.IDateEditor
,ActionListener
,FocusListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,CaretListener
,Scrollable
,SwingConstants
public class JCalendarDateEditor
extends JFormattedTextField
implements com.toedter.calendar.IDateEditor, CaretListener, FocusListener, ActionListener
This class is just a
JTextFieldDateEditor
that
allows the user to enter either the day within (current) year or a
McIDAS-X style "julian day" (YYYYDDD
or YYDDD
),
in addition to the formatting allowed by JTextFieldDateEditor
.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JFormattedTextField
JFormattedTextField.AbstractFormatter, JFormattedTextField.AbstractFormatterFactory
Nested classes/interfaces inherited from class javax.swing.JTextField
JTextField.AccessibleJTextField
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding
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 TypeFieldDescriptionprivate final SimpleDateFormat
ParseYYDDD
dates.private static final Pattern
MatchYYDDD
dates.private Calendar
protected Color
protected Date
protected SimpleDateFormat
protected String
protected com.toedter.calendar.DateUtil
private final SimpleDateFormat
ParseDDD
dates (even if they are one or two digits).private static final Pattern
Match day of year.private int
private boolean
private boolean
private static final org.slf4j.Logger
protected MaskFormatter
protected String
private int
private int
protected char
private int
private static final long
private final SimpleDateFormat
ParseYYYYDDD
dates.private static final Pattern
MatchYYYYDDD
.Fields inherited from class javax.swing.JFormattedTextField
COMMIT, COMMIT_OR_REVERT, PERSIST, REVERT
Fields inherited from class javax.swing.JTextField
notifyAction
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
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
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
-
Constructor Summary
ConstructorsConstructorDescriptionJCalendarDateEditor
(boolean showMask, String datePattern, String maskPattern, char placeholder) JCalendarDateEditor
(String datePattern, String maskPattern, char placeholder) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Validates the typed date and sets it (only if it is valid).private Date
attemptParsing
(String text) void
caretUpdate
(CaretEvent event) After any user input, the value of the textfield is proofed.private void
createMaskFromDatePattern
(String datePattern) Creates a mask from a date pattern.void
void
focusLost
(FocusEvent focusEvent) getDate()
Returns the preferred size, enough to accommodate longest date someone could enterboolean
Returnstrue
, if the mask is visible.void
protected void
Sets the date.void
setDateFormatString
(String dateFormatString) void
setEnabled
(boolean b) Enables and disabled the compoment.void
void
setMaskVisible
(boolean isMaskVisible) Sets the mask visible.void
setMaxSelectableDate
(Date max) void
setMinSelectableDate
(Date min) void
setSelectableDateRange
(Date min, Date max) Methods inherited from class javax.swing.JFormattedTextField
commitEdit, getActions, getFocusLostBehavior, getFormatter, getFormatterFactory, getUIClassID, getValue, invalidEdit, isEditValid, processFocusEvent, processInputMethodEvent, setDocument, setFocusLostBehavior, setFormatter, setFormatterFactory, setValue
Methods inherited from class javax.swing.JTextField
actionPropertyChanged, addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getScrollOffset, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setColumns, setFont, setHorizontalAlignment, setScrollOffset
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, modelToView2D, moveCaretPosition, paste, print, print, print, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, restoreComposedText, saveComposedText, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, viewToModel2D, write
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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, 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, 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, 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, processHierarchyBoundsEvent, processHierarchyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, 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
Methods inherited from interface com.toedter.calendar.IDateEditor
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
serialVersionUID
- See Also:
-
dayOnly
Match day of year. -
yearDay
MatchYYYYDDD
. -
badYearDay
MatchYYDDD
dates. -
logger
-
date
-
dateFormatter
-
dayOfYear
ParseDDD
dates (even if they are one or two digits). -
yearAndDay
ParseYYYYDDD
dates. -
badYearAndDay
ParseYYDDD
dates. -
maskFormatter
-
datePattern
-
maskPattern
-
placeholder
-
darkGreen
-
dateUtil
-
isMaskVisible
-
ignoreDatePatternChange
-
hours
-
minutes
-
seconds
-
millis
-
calendar
-
-
Constructor Details
-
JCalendarDateEditor
public JCalendarDateEditor() -
JCalendarDateEditor
-
JCalendarDateEditor
public JCalendarDateEditor(boolean showMask, String datePattern, String maskPattern, char placeholder)
-
-
Method Details
-
getDate
- Specified by:
getDate
in interfacecom.toedter.calendar.IDateEditor
-
setDate
- Specified by:
setDate
in interfacecom.toedter.calendar.IDateEditor
-
setDate
Sets the date.- Parameters:
date
- the datefirePropertyChange
- true, if the date property should be fired.
-
setDateFormatString
- Specified by:
setDateFormatString
in interfacecom.toedter.calendar.IDateEditor
-
getDateFormatString
- Specified by:
getDateFormatString
in interfacecom.toedter.calendar.IDateEditor
-
getUiComponent
- Specified by:
getUiComponent
in interfacecom.toedter.calendar.IDateEditor
-
attemptParsing
-
caretUpdate
After any user input, the value of the textfield is proofed. Depending on being a valid date, the value is colored green or red.- Specified by:
caretUpdate
in interfaceCaretListener
- Parameters:
event
- Caret event.
-
focusLost
- Specified by:
focusLost
in interfaceFocusListener
-
checkText
-
focusGained
- Specified by:
focusGained
in interfaceFocusListener
-
setLocale
-
createMaskFromDatePattern
Creates a mask from a date pattern. This is a very simple (and incomplete) implementation thet works only with numbers. A date pattern of "MM/dd/yy" will result in the mask "##/##/##". Probably you want to override this method if it does not fit your needs.- Parameters:
datePattern
- Date pattern.- Returns:
- the mask
-
isMaskVisible
Returnstrue
, if the mask is visible.- Returns:
true
, if the mask is visible.
-
setMaskVisible
Sets the mask visible.- Parameters:
isMaskVisible
- Whether or not the mask should be visible.
-
getPreferredSize
Returns the preferred size, enough to accommodate longest date someone could enter- Overrides:
getPreferredSize
in classJTextField
-
actionPerformed
Validates the typed date and sets it (only if it is valid).- Specified by:
actionPerformed
in interfaceActionListener
-
setEnabled
Enables and disabled the compoment. It also fixes the background bug 4991597 and sets the background explicitely to a TextField.inactiveBackground.- Specified by:
setEnabled
in interfacecom.toedter.calendar.IDateEditor
- Overrides:
setEnabled
in classJComponent
-
getMaxSelectableDate
- Specified by:
getMaxSelectableDate
in interfacecom.toedter.calendar.IDateEditor
-
getMinSelectableDate
- Specified by:
getMinSelectableDate
in interfacecom.toedter.calendar.IDateEditor
-
setMaxSelectableDate
- Specified by:
setMaxSelectableDate
in interfacecom.toedter.calendar.IDateEditor
-
setMinSelectableDate
- Specified by:
setMinSelectableDate
in interfacecom.toedter.calendar.IDateEditor
-
setSelectableDateRange
- Specified by:
setSelectableDateRange
in interfacecom.toedter.calendar.IDateEditor
-