Package com.portal.pfc.ui.datetime
Class DateSelector
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.portal.pfc.ui.datetime.DateSelector
- All Implemented Interfaces:
ImageObserver,MenuContainer,PropertyChangeListener,Serializable,EventListener,Accessible
- Direct Known Subclasses:
PIADateField
A control which allows the user to enter/change a date. The date can
be entered into the textfield manually, or it can be selected by popping
up a small calendar window which displays dates one month at a time. The
calendar popup will always display the current date in a specified color
(default red) and the user selected date (if different from the current
date) in a different color (default yellow).
Note that this uses a JPopupMenu to display the popup calendar, and there are known clipping bugs with JPopupMenu instances in modal dialogs. Note: Any changes done to this class might also need to be copied to DateTimeSelector and TimeSelector
Note that this uses a JPopupMenu to display the popup calendar, and there are known clipping bugs with JPopupMenu instances in modal dialogs. Note: Any changes done to this class might also need to be copied to DateTimeSelector and TimeSelector
- Author:
- Kapono Carter
- 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 TypeFieldDescriptionprotected JPopupMenuprotected JTextFieldprotected MiniCalprotected booleanprotected JButtonFields 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
ConstructorsConstructorDescriptionCreates a new DateSelector instance comprised of a JTextField and an selectable icon to the right of the JTextField.DateSelector(boolean showDate) Creates a new DateSelector instance comprised of a JTextField and an selectable icon to the right of the JTextField. -
Method Summary
Modifier and TypeMethodDescriptionvoidgetDate()Retrieves the current date represented by this component.Retrieves the date pattern used to render the date into the textfieldRetrieves the color representing the user selected datebooleanIndicates if the tooltip is displayed or not.getText()Retrieves the contents of the date textfield.Retrieves the color representing "today"voidProvides a way to force the pop-up to hidebooleanReturns true if component is editablevoidvoidvoidvoidOverride requestFocus to pass it on to the actual text fieldvoidvoidsetAccessibleParent(Accessible parent) voidsetBackground(Color bg) voidEstablishes the current date represented by this componentvoidsetEditable(boolean editable) Set editability of componentvoidsetEnabled(boolean b) Enables/disables the subcomponents that comprise the main componentvoidvoidsetPattern(String p) voidChange the color representing the user selected date.voidsetShowPatternTip(boolean b) Turns on/off the tooltip displaying the current date pattern.voidsetTextEditable(boolean b) Set editability of text field that displays datevoidChange the color representing "today".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, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, 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, 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, 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
-
dateTF
-
popupInvoker
-
calPopup
-
minical
-
normalizeYear
protected boolean normalizeYear
-
-
Constructor Details
-
DateSelector
public DateSelector()Creates a new DateSelector instance comprised of a JTextField and an selectable icon to the right of the JTextField. Selecting the icon will display a calendar "month" in a popup menu. -
DateSelector
public DateSelector(boolean showDate) Creates a new DateSelector instance comprised of a JTextField and an selectable icon to the right of the JTextField. Selecting the icon will display a calendar "month" in a popup menu.- Parameters:
showDate- determines if today's date is displayed in the textfield initially. If showDate is false, the textfield is initially blank and the tooltip (containing the date pattern) is turned on.
-
-
Method Details
-
hidePopup
public void hidePopup()Provides a way to force the pop-up to hide -
requestFocus
public void requestFocus()Override requestFocus to pass it on to the actual text field- Overrides:
requestFocusin classJComponent
-
setLayout
-
getBackground
- Overrides:
getBackgroundin classComponent
-
setBackground
- Overrides:
setBackgroundin classJComponent
-
addChangeListener
-
removeChangeListener
-
paintComponent
- Overrides:
paintComponentin classJComponent
-
setShowPatternTip
public void setShowPatternTip(boolean b) Turns on/off the tooltip displaying the current date pattern. This is potentially useful if the user doesn't know what format to manually enter a date string.- Parameters:
b- the flag dictating if the tooltip should be on or off
-
setEditable
public void setEditable(boolean editable) Set editability of component- Parameters:
editable- New editable flag
-
setTextEditable
public void setTextEditable(boolean b) Set editability of text field that displays date- Parameters:
b- If true, the date text field is editable; otherwise it is disabled.
-
isEditable
public boolean isEditable()Returns true if component is editable- Returns:
- true if component is editable
-
getShowPatternTip
public boolean getShowPatternTip()Indicates if the tooltip is displayed or not.- Returns:
- the state of the tooltip containing the current date pattern
-
getPattern
Retrieves the date pattern used to render the date into the textfield- Returns:
- the date format pattern
-
setPattern
-
getText
Retrieves the contents of the date textfield.- Returns:
- the contents of the date textfield
-
getDate
Retrieves the current date represented by this component. If the date manually entered by the user is not a valid date, an IllegalArgumentException is thrown.- Returns:
- the current date
- Throws:
IllegalArgumentException
-
setDate
Establishes the current date represented by this component- Parameters:
d- the new date
-
setTodayColor
Change the color representing "today". Today is red by default- Parameters:
c- the new today color
-
getTodayColor
Retrieves the color representing "today"- Returns:
- the color representing "today"
-
setSelectedDateColor
Change the color representing the user selected date. This is yellow by default.- Parameters:
c- the new current date color
-
getSelectedDateColor
Retrieves the color representing the user selected date- Returns:
- the color representing the user selected date
-
setEnabled
public void setEnabled(boolean b) Enables/disables the subcomponents that comprise the main component- Overrides:
setEnabledin classJComponent- Parameters:
b- If true, the component is enabled; otherwise it is disabled.
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener
-
setAccessibleName
-
setAccessibleParent
-