|
JDatePicker v4.3 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
com.standbysoft.component.date.swing.JDateComponent
com.standbysoft.component.date.swing.JDateEditComponent
JDateEditComponent is the base class for all date editing
components. You can find task-oriented documentation and examples of using
date edit components in Using a JDateEditComponent,
a section in The JDatePicker Suite Tutorial.
By default, dates are edited using an internal editor that forces
users to type correct dates according to a date format. Although there are a
few ways to specify the date format, we recommend using either a
string pattern or a
DateFormat style.
The component can also accept free text
entries that are converted to dates using a date parser.
This makes it possible to plug special parsers that can convert shortcut
strings like 'today' to an appropriate date. If you are using the structured
date editor (freeText is false), then you can enable or disable
the autoCentury property. If set to
true, short years like 80 will be converted to long ones like 1980.
An important part of this component's API is reserved for date validation.
You can test if a date is valid,
execute your own action when the date is invalid and
ask for a certain edit to be commited. For a date to be
valid, it must be accepted by the date selection model. A date edit component
can be configured to indicate what must happen at validation time. Such
properties are:
| Nested Class Summary |
| Nested classes inherited from class com.standbysoft.component.date.swing.JDateComponent |
JDateComponent.DateAction, JDateComponent.RollDateAction, JDateComponent.SelectFirstDayAction, JDateComponent.SelectLastDayAction, JDateComponent.SelectNoneAction, JDateComponent.SelectTodayAction |
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
protected boolean |
autoRestore
|
protected boolean |
autoValidate
|
protected boolean |
beepOnError
|
protected java.text.DateFormat |
dateFormat
The date format used by this component to display dates. |
protected java.lang.String |
dateFormatPattern
The string pattern used to specify the date format. |
protected int |
dateFormatStyle
The DateFormat style (SHORT, MEDIUM, LONG, FULL) used to
specify the date format. |
protected DateModel |
dateModel
|
protected DateListener |
dateModelListener
|
protected DateParser |
dateParser
|
protected java.lang.String |
emptySelectionText
|
protected boolean |
freeText
|
protected int |
horizontalAlignment
|
protected java.lang.String |
text
|
protected int |
timeFormatStyle
The DateFormat style (SHORT, MEDIUM, LONG, FULL) used to
specify the time format. |
| Fields inherited from class com.standbysoft.component.date.swing.JDateComponent |
actionCommand, calendar, dateSelectionModel, dateSelectionModelListener, locale, selectFirstDayAction, selectLastDayAction, selectNextDayAction, selectNoneAction, selectPreviousDayAction, selectSameDayNextMonthAction, selectSameDayNextWeekAction, selectSameDayNextYearAction, selectSameDayPreviousMonthAction, selectSameDayPreviousWeekAction, selectSameDayPreviousYearAction, selectTodayAction, timeZone |
| Fields inherited from class javax.swing.JComponent |
accessibleContext, 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 |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| 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 |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
JDateEditComponent()
Creates a default date field that has the today date selected. |
|
JDateEditComponent(DateSelectionModel model)
|
|
| Method Summary | |
void |
addDateListener(DateListener listener)
Registers a date listener that will receive notifications when the date model changes. |
void |
commitEdit()
Makes the currently edited date to be the selected date but only if it is valid. |
protected void |
fireDateChanged(DateEvent evt)
|
protected void |
fireDateFieldChanged(DateEvent evt)
|
protected void |
fireDateFieldCleared(DateEvent evt)
|
int |
getAutoCenturyYear()
Detrmines the year used to build the long year when short years are used. |
java.text.DateFormat |
getDateFormat()
Returns the format used to display and edit the selected date. |
DateModel |
getDateModel()
Returns the date model used by this component. |
DateParser |
getDateParser()
Determines the date parser that converts free text entries into dates. |
java.lang.String |
getEmptySelectionText()
Returns the text displayed by this component when there is no date selected. |
int |
getHorizontalAlignment()
Returns the horizontal alignment of the date. |
java.lang.String |
getSelectedDateAsText()
Returns the selected date in text form. |
java.lang.String |
getText()
|
protected void |
invalidEdit()
Invoked on an invalid date input. |
boolean |
isAutoCentury()
Determines whether century is automatically added to the year field if its value is less than 100. |
boolean |
isAutoRestore()
Determines whether an invalid date should be automatically restored to the last valid date. |
boolean |
isAutoValidate()
Determines whether the date edited by this component should be validated when focus is lost. |
boolean |
isBeepOnError()
Determines whether a beep will sound if the typed date is not valid, at validation time. |
boolean |
isEditValid()
Determines whether the current edited date is valid. |
boolean |
isFreeText()
Determines whether free text date entries are allowed. |
void |
removeDateListener(DateListener listener)
Removes a date listener registered on this component. |
void |
setAutoCentury(boolean enabled)
Specifies whether century is automatically added to the year field if its value is less than 100. |
void |
setAutoCenturyYear(int year)
Specifies the year used to build the long year when short years are used. |
void |
setAutoRestore(boolean enabled)
Specifies whether an invalid date should be automatically restored to the last valid date. |
void |
setAutoValidate(boolean enabled)
Specifies whether the temporary represented date is validated when the component loses focus. |
void |
setBeepOnError(boolean enabled)
Specifies whether a beep will sound if the typed date is not valid, at validation time. |
void |
setDateFormat(java.text.DateFormat format)
Specifies the format used to display and edit the date. |
void |
setDateFormat(int dateFormat)
Specifies the date format by means of DateFormat predefined
styles. |
void |
setDateFormat(int dateFormat,
int timeFormat)
Specifies a date format that includes time information by means of DateFormat predefined styles. |
void |
setDateFormat(java.lang.String pattern)
Specifies the date format by means of programmer defined string patterns. |
void |
setDateModel(DateModel model)
Specifies a new date model for this component. |
void |
setDateParser(DateParser parser)
Specifies the date parser that will be used to convert free text entries into dates. |
void |
setDateSelectionModel(DateSelectionModel model)
Specifies a new selection model for this component. |
void |
setEmptySelectionText(java.lang.String text)
Specifies the text displayed by this component when there is no date selected. |
void |
setFreeText(boolean enabled)
Specifies whether free text date entries are allowed. |
void |
setHorizontalAlignment(int alignment)
Sets the horizontal alignment of the date. |
void |
setLocale(java.util.Locale locale)
Overrides the parent locale method in order to update the date format, if possible. |
void |
setSelectedDate(java.util.Date date)
Overridden to implement special behavior for a date edit component that cannot be implemented in the base class. |
void |
setText(java.lang.String text)
|
void |
setTimeZone(java.util.TimeZone zone)
Overriden in order to configure the internal date model to use the new time zone. |
| Methods inherited from class com.standbysoft.component.date.swing.JDateComponent |
addActionListener, addDateSelectionListener, fireActionEvent, fireDateSelectionChanged, fireDisabledDatesChanged, fireDisabledDateSelectionAttempted, fireEmptySelectionAllowedChanged, fireSelectionModeChanged, getActionCommand, getCalendar, getDateSelectionModel, getLocale, getSelectedDate, getTimeZone, getUI, isEmptySelectionAllowed, removeActionListener, removeDateSelectionListener, setActionCommand, setEmptySelectionAllowed, setUI, updateUI |
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.text.DateFormat dateFormat
protected int dateFormatStyle
DateFormat style (SHORT, MEDIUM, LONG, FULL) used to
specify the date format. When the date format is specified otherwise
than using a style, this field is -1.
setDateFormat(int, int)protected int timeFormatStyle
DateFormat style (SHORT, MEDIUM, LONG, FULL) used to
specify the time format. When the date format is specified otherwise
than using a style, this field is -1.
setDateFormat(int, int)protected java.lang.String dateFormatPattern
null.
setDateFormat(String)protected java.lang.String emptySelectionText
protected boolean autoRestore
protected boolean autoValidate
protected boolean beepOnError
protected DateModel dateModel
protected DateListener dateModelListener
protected DateParser dateParser
protected boolean freeText
protected int horizontalAlignment
protected java.lang.String text
| Constructor Detail |
public JDateEditComponent()
public JDateEditComponent(DateSelectionModel model)
| Method Detail |
public void setSelectedDate(java.util.Date date)
setSelectedDate in class JDateComponentdate - date to be selectedpublic void setDateModel(DateModel model)
model - new date model to be used by this componentpublic DateModel getDateModel()
setDateModel(DateModel)public void addDateListener(DateListener listener)
listener - listener that is registeredsetDateModel(DateModel),
removeDateListener(DateListener)public void removeDateListener(DateListener listener)
listener - listener that is removedpublic void setAutoCentury(boolean enabled)
enabled - true if century is automatically added;
false otherwiseDateModel.setAutoCentury(boolean)public boolean isAutoCentury()
true if century is automatically added;
false otherwise.DateModel.isAutoCentury()public void setAutoCenturyYear(int year)
year - year used to build the long year when short years are usedDateModel.setAutoCenturyYear(int)public int getAutoCenturyYear()
DateModel.getAutoCenturyYear()public java.lang.String getEmptySelectionText()
setEmptySelectionText(String)public void setEmptySelectionText(java.lang.String text)
text - text displayed by this component when there is no date selectedpublic java.lang.String getSelectedDateAsText()
Returns the selected date in text form. This text form is obtained
by formatting the currently selected date using the current
date format. If the date is null
then the returned string is the null
text.
This method is particularly useful if you need to return the text
representation of the date as a custom string. For instance, you could
override it to represent the Christmas date as Christmas '01
instead of Dec 25, 2001.
The text returned by this method is used to represent the dates in
date edit components when the free text
mode is enabled. It's sort of a renderer but only in text form.
getEmptySelectionText(),
getDateFormat()public void setDateSelectionModel(DateSelectionModel model)
setDateSelectionModel in class JDateComponentmodel - new selection model to be used by this componentpublic java.text.DateFormat getDateFormat()
setDateFormat(DateFormat)public void setDateFormat(java.text.DateFormat format)
Specifies the format used to display and edit the date. This is
the most generic way of specifying the format. The API also contains two
other methods that can specify the format as an
int constant and as a
string pattern.
Keep in mind that if the locale is changed for this component and you are using this method to specify the date format, you would have to change the date format too.
On the other hand, if you are using the other two methods to specify the date format, it will be updated automatically when the locale is changed.
format - actual date format
java.lang.NullPointerException - if the given format is nullsetDateFormat(int),
setDateFormat(String)public void setDateFormat(int dateFormat)
DateFormat predefined
styles. The date format is built automatically using the specified
style and the current locale. Actually, this is just a wrapper method
that makes the date format setting easier.
dateFormat - format used to display the selected date. Valid values are
DateFormat.SHORT, DateFormat.MEDIUM,
DateFormat.LONG or DateFormat.FULL.setDateFormat(DateFormat),
setDateFormat(String),
setDateFormat(int, int)
public void setDateFormat(int dateFormat,
int timeFormat)
DateFormat predefined styles.
dateFormat - format used to display the date part of the date. Valid values are
DateFormat.SHORT, DateFormat.MEDIUM,
DateFormat.LONG or DateFormat.FULL.timeFormat - format used to display the time part of the date. Valid values are
DateFormat.SHORT, DateFormat.MEDIUM,
DateFormat.LONG or DateFormat.FULL.setDateFormat(DateFormat),
setDateFormat(String),
setDateFormat(int)public void setDateFormat(java.lang.String pattern)
Specifies the date format by means of programmer defined string patterns.
The date format is built automatically using the specified pattern and
the current locale. Actually, this is just a wrapper method that makes
the date format setting easier.
A complete description of the syntax used to define date format patterns can be found in the Java Tutorial. For instance if you want to format dates like "12:08 PM" you must use the string "h:mm a" as pattern.
pattern - new date pattern that will be used to format dates for
display or editingsetDateFormat(DateFormat),
setDateFormat(int)public void setLocale(java.util.Locale locale)
setLocale in class JDateComponentlocale - creates a specific configuration for this componentpublic void setText(java.lang.String text)
public java.lang.String getText()
public void setDateParser(DateParser parser)
parser - date parser that will be used to convert free text entries
into datessetFreeText(boolean)public DateParser getDateParser()
setDateParser(DateParser)public void setFreeText(boolean enabled)
enabled - true if free text is enabled; false
otherwisesetDateParser(DateParser)public boolean isFreeText()
true if free text date entries are allowed; false otherwise.setFreeText(boolean)public void setAutoValidate(boolean enabled)
enabled - true if validation should occur when focus is lost;
false otherwiseJDateComponent.getSelectedDate()public boolean isAutoValidate()
true if validation should occur when focus is lost;
false otherwise.setAutoValidate(boolean)public void setBeepOnError(boolean enabled)
enabled - true if the beep will sound on invalid entries;
false otherwiseinvalidEdit()public boolean isBeepOnError()
true if the beep will sound on invalid entries;
false otherwise.setBeepOnError(boolean)protected void invalidEdit()
setBeepOnError(boolean)public boolean isEditValid()
Determines whether the current edited date is valid. A valid date is a date that can be selected by the date selection model.
true if the date is accepted by the date selection
model; false otherwise.DateSelectionModel.isDateSelectable(Date)public void commitEdit()
isEditValid()public void setAutoRestore(boolean enabled)
enabled - true if at validation time, an invalid date should
be automatically restored to the last valid date; false otherwisesetAutoValidate(boolean)public boolean isAutoRestore()
true if at validation time, an invalid date should
be automatically restored to the last valid date; false otherwise.setAutoRestore(boolean)public void setHorizontalAlignment(int alignment)
alignment - how to align the date. Acceptable values are:
JDateEditComponent.LEFT, JDateEditComponent.CENTER,
JDateEditComponent.RIGHT, JDateEditComponent.LEADING
(the default) or JDateEditComponent.TRAILING
java.lang.IllegalArgumentException - if alignment is not a validpublic int getHorizontalAlignment()
setHorizontalAlignment(int)public void setTimeZone(java.util.TimeZone zone)
setTimeZone in class JDateComponentzone - new time zone for this componentprotected void fireDateFieldChanged(DateEvent evt)
protected void fireDateFieldCleared(DateEvent evt)
protected void fireDateChanged(DateEvent evt)
|
JDatePicker v4.3 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Visit www.jdatepicker.com for further information or send us your suggestions.
Copyright © 2003-2007 Stand By Soft Ltd. All Rights Reserved.