public class DatePicker extends JPanel implements CustomPopup.CustomPopupCloseListener
// Basic usage example:
// Create a date picker.
DatePicker datePicker = new DatePicker();
// Create a panel, and add the date picker.
JPanel panel = new JPanel();
panel.add(datePicker);
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
DatePicker()
Constructor with Default Values, Create a date picker instance using the default operating
system locale and language, and default date picker settings.
|
DatePicker(DatePickerSettings settings)
Constructor with Custom Settings, Create a date picker instance using the supplied date
picker settings.
|
Modifier and Type | Method and Description |
---|---|
void |
addComponentListener(ComponentListener listener) |
void |
addDateChangeListener(DateChangeListener listener)
addDateChangeListener, This adds a date change listener to this date picker.
|
void |
clear()
clear, This will clear the date picker text.
|
void |
closePopup()
closePopup, This closes the calendar popup.
|
Convert |
convert()
convert, This is used to access the Convert class instance.
|
protected void |
fireComponentEvent(ComponentEvent e) |
int |
getBaseline(int width,
int height)
getBaseline, This returns the baseline value of the dateTextField.
|
JTextField |
getComponentDateTextField()
getComponentDateTextField, Returns the date text field for this date picker.
|
JButton |
getComponentToggleCalendarButton()
getComponentToggleCalendarButton, Returns the "toggle calendar" button for this date picker.
|
LocalDate |
getDate()
getDate, This returns the last valid date, or returns null to represent an empty date.
|
ArrayList<DateChangeListener> |
getDateChangeListeners()
getDateChangeListeners, This returns a new ArrayList, that contains any date change listeners
that are registered with this DatePicker.
|
String |
getDateStringOrEmptyString()
getDateStringOrEmptyString, This returns the last valid date in an ISO-8601 formatted string
"uuuu-MM-dd".
|
String |
getDateStringOrSuppliedString(String emptyDateString)
getDateStringOrSuppliedString, This returns the last valid date in an ISO-8601 formatted
string "uuuu-MM-dd".
|
DatePickerSettings |
getSettings()
getSettings, This returns the date picker settings instance.
|
String |
getText()
getText, This returns the current text that is present in the date picker text field.
|
boolean |
isDateAllowed(LocalDate date)
isDateAllowed, This checks to see if the specified date is allowed by any currently set veto
policy, and allowed by the current setting of allowEmptyDates.
|
boolean |
isEnabled()
isEnabled, Returns true if this component is enabled, otherwise returns false.
|
boolean |
isPopupOpen()
isPopupOpen, This returns true if the calendar popup is open.
|
boolean |
isTextFieldValid()
isTextFieldValid, This returns true if, and only if, the text field contains a parsable date
or a valid empty string.
|
boolean |
isTextValid(String text)
isTextValid, This function can be used to see if the supplied text represents a "valid date"
according to the settings of this date picker.
|
void |
openPopup()
openPopup, This opens the calendar popup.
|
void |
removeComponentListener(ComponentListener listener) |
void |
removeDateChangeListener(DateChangeListener listener)
removeDateChangeListener, This removes the specified date change listener from this date
picker.
|
void |
setDate(LocalDate optionalDate)
setDate, This sets this date picker to the specified date.
|
void |
setDateToToday()
setDateToToday, This sets the date to today's date.
|
void |
setEnabled(boolean enabled)
setEnabled, This enables or disables the date picker.
|
void |
setLocale(Locale locale)
setLocale, The locale for a DatePicker should generally be set in the DatePickerSettings.
|
void |
setSettings(DatePickerSettings settings)
setSettings, This will set the settings instance for this date picker.
|
void |
setText(String text)
setText, This sets the text of the date picker text field to the supplied value.
|
void |
setTextFieldToValidStateIfNeeded()
setTextFieldToValidStateIfNeeded,
This function will check the contents of the text field, and when needed, will set the text
to match the "last valid date" in a standardized valid format.
|
void |
togglePopup()
togglePopup, This creates and shows a calendar popup.
|
String |
toString()
toString, This returns the last valid date in an ISO-8601 formatted string "uuuu-MM-dd".
|
void |
zDrawTextFieldIndicators()
zDrawTextFieldIndicators, This will draw the text field indicators, to indicate to the user
the state of any text in the text field, including the validity of any date that has been
typed.
|
void |
zEventCustomPopupWasClosed(CustomPopup popup)
zEventCustomPopupWasClosed, This is called automatically whenever the CustomPopup that is
associated with this date picker is closed.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, 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, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
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
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, getPeer, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
public DatePicker()
public DatePicker(DatePickerSettings settings)
public void setSettings(DatePickerSettings settings)
public void addDateChangeListener(DateChangeListener listener)
public void clear()
public void closePopup()
public Convert convert()
public JButton getComponentToggleCalendarButton()
public int getBaseline(int width, int height)
getBaseline
in class JComponent
public JTextField getComponentDateTextField()
public LocalDate getDate()
Additional Text Validation Details: Whenever the current date picker text is not valid, the value returned by getDate() will generally not match the date picker text. The date picker can contain invalid text whenever both items (1) and (2) below are true: 1) The user has manually typed text that cannot be parsed by the parsing formats into a valid date, or the user has typed a date that is vetoed by a current veto policy, or the user has cleared (or left only whitespace) in the text when allowEmptyDates is false. 2) The date picker text field has continued to have focus, and therefore the automatic validation (revert/commit) process has not yet occurred.
public ArrayList<DateChangeListener> getDateChangeListeners()
public String getDateStringOrEmptyString()
public String getDateStringOrSuppliedString(String emptyDateString)
public DatePickerSettings getSettings()
public String getText()
public boolean isDateAllowed(LocalDate date)
public boolean isEnabled()
public boolean isPopupOpen()
public boolean isTextFieldValid()
public boolean isTextValid(String text)
public void openPopup()
public void removeDateChangeListener(DateChangeListener listener)
public final void setDate(LocalDate optionalDate)
public void setDateToToday()
public void setEnabled(boolean enabled)
setEnabled
in class JComponent
public void setLocale(Locale locale)
public void setText(String text)
public void setTextFieldToValidStateIfNeeded()
public String toString()
public void togglePopup()
public void zDrawTextFieldIndicators()
public void zEventCustomPopupWasClosed(CustomPopup popup)
zEventCustomPopupWasClosed
in interface CustomPopup.CustomPopupCloseListener
public void addComponentListener(ComponentListener listener)
public void removeComponentListener(ComponentListener listener)
protected void fireComponentEvent(ComponentEvent e)
Copyright © 2017. All rights reserved.