public class DateSelector extends JPanel implements PropertyChangeListener
JPanel.AccessibleJPanelJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
protected JPopupMenu |
calPopup |
protected JTextField |
dateTF |
protected MiniCal |
minical |
protected boolean |
normalizeYear |
protected JButton |
popupInvoker |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
DateSelector()
Creates 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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(ChangeListener l) |
Color |
getBackground() |
Date |
getDate()
Retrieves the current date represented by this component.
|
String |
getPattern()
Retrieves the date pattern used to render the date into the textfield
|
Color |
getSelectedDateColor()
Retrieves the color representing the user selected date
|
boolean |
getShowPatternTip()
Indicates if the tooltip is displayed or not.
|
String |
getText()
Retrieves the contents of the date textfield.
|
Color |
getTodayColor()
Retrieves the color representing "today"
|
void |
hidePopup()
Provides a way to force the pop-up to hide
|
boolean |
isEditable()
Returns true if component is editable
|
void |
paintComponent(Graphics g) |
void |
propertyChange(PropertyChangeEvent e) |
void |
removeChangeListener(ChangeListener l) |
void |
requestFocus()
Override requestFocus to pass it on to the actual text field
|
void |
setAccessibleName(String s) |
void |
setAccessibleParent(Accessible parent) |
void |
setBackground(Color bg) |
void |
setDate(Date d)
Establishes the current date represented by this component
|
void |
setEditable(boolean editable)
Set editability of component
|
void |
setEnabled(boolean b)
Enables/disables the subcomponents that comprise the main component
|
void |
setLayout(LayoutManager lm) |
void |
setPattern(String p) |
void |
setSelectedDateColor(Color c)
Change the color representing the user selected date.
|
void |
setShowPatternTip(boolean b)
Turns on/off the tooltip displaying the current date pattern.
|
void |
setTextEditable(boolean b)
Set editability of text field that displays date
|
void |
setTodayColor(Color c)
Change the color representing "today".
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIaddAncestorListener, 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, updateadd, 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, validateTreeaction, 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, getPeer, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleprotected JTextField dateTF
protected JButton popupInvoker
protected JPopupMenu calPopup
protected MiniCal minical
protected boolean normalizeYear
public DateSelector()
public DateSelector(boolean showDate)
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.public void hidePopup()
public void requestFocus()
requestFocus in class JComponentpublic void setLayout(LayoutManager lm)
public Color getBackground()
getBackground in class Componentpublic void setBackground(Color bg)
setBackground in class JComponentpublic void addChangeListener(ChangeListener l)
public void removeChangeListener(ChangeListener l)
public void paintComponent(Graphics g)
paintComponent in class JComponentpublic void setShowPatternTip(boolean b)
b - the flag dictating if the tooltip should be on or offpublic void setEditable(boolean editable)
editable - New editable flagpublic void setTextEditable(boolean b)
b - If true, the date text field is editable; otherwise it is disabled.public boolean isEditable()
public boolean getShowPatternTip()
public String getPattern()
public void setPattern(String p)
public String getText()
public Date getDate() throws IllegalArgumentException
IllegalArgumentExceptionpublic void setDate(Date d)
d - the new datepublic void setTodayColor(Color c)
c - the new today colorpublic Color getTodayColor()
public void setSelectedDateColor(Color c)
c - the new current date colorpublic Color getSelectedDateColor()
public void setEnabled(boolean b)
setEnabled in class JComponentb - If true, the component is enabled; otherwise it is disabled.public void propertyChange(PropertyChangeEvent e)
propertyChange in interface PropertyChangeListenerpublic void setAccessibleName(String s)
public void setAccessibleParent(Accessible parent)
Copyright © 2003, 2023, Oracle and/or its affiliates.