|
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
JDateComponent is the base class for all date selection components.
You can find task-oriented documentation and examples of using date components
in Using a JDateComponent,
a section in The JDatePicker Suite Tutorial.
Its purpose is to provide common functionality for all such components. Most of its methods make it easier to work with the date selection model; they just delegate further to the selection model that is set on the component.
addDateSelectionListener(DateSelectionListener)removeDateSelectionListener(DateSelectionListener)isEmptySelectionAllowed()setEmptySelectionAllowed(boolean)Besides that, this class provides a few actions that alter the dates selected by the date selection model. Here is how these actions can be used on a date component.
InputMap im = dateComponent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); ActionMap am = dateComponent.getActionMap(); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), JDateComponent.selectNextDayAction); am.put(JDateComponent.selectNextDayAction, new JDateComponent.RollDateAction(Calendar.DATE, true)); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), JDateComponent.selectPreviousDayAction); am.put(JDateComponent.selectPreviousDayAction, new JDateComponent.RollDateAction(Calendar.DATE, false)); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), JDateComponent.selectSameDayPreviousWeekAction); am.put(JDateComponent.selectSameDayPreviousWeekAction, new JDateComponent.RollDateAction(Calendar.WEEK_OF_YEAR, false));
| Nested Class Summary | |
static class |
JDateComponent.DateAction
|
static class |
JDateComponent.RollDateAction
This action is used to increment/decrement the value of one date field with one unit. |
static class |
JDateComponent.SelectFirstDayAction
This action is used to select the first selectable day of the currently selected month. |
static class |
JDateComponent.SelectLastDayAction
This action is used to select the last selectable day of the currently selected month. |
static class |
JDateComponent.SelectNoneAction
This action is used to deselect all selected dates. |
static class |
JDateComponent.SelectTodayAction
This action is used to select the today date. |
| 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 java.lang.String |
actionCommand
The name of the action command used when an action event is fired by this component. |
protected java.util.Calendar |
calendar
|
protected DateSelectionModel |
dateSelectionModel
The selection model used by this component to select one or more dates. |
protected DateSelectionListener |
dateSelectionModelListener
Listener that takes date selection listener events from the model and fires them further away as events generated by this component. |
protected java.util.Locale |
locale
|
static java.lang.String |
selectFirstDayAction
Name of the action to select the first selectable day in a month. |
static java.lang.String |
selectLastDayAction
Name of the action to select the last selectable day in a month. |
static java.lang.String |
selectNextDayAction
Name of the action to select the next selectable day in a month. |
static java.lang.String |
selectNoneAction
Name of the action to unselect all selected dates. |
static java.lang.String |
selectPreviousDayAction
Name of the action to select the previous selectable day in a month. |
static java.lang.String |
selectSameDayNextMonthAction
Name of the action to select the same day of month, next month. |
static java.lang.String |
selectSameDayNextWeekAction
Name of the action to select the same day of week, next week. |
static java.lang.String |
selectSameDayNextYearAction
Name of the action to select the same day of year, next year. |
static java.lang.String |
selectSameDayPreviousMonthAction
Name of the action to select the same day of month, previous month. |
static java.lang.String |
selectSameDayPreviousWeekAction
Name of the action to select the same day of week, previous week. |
static java.lang.String |
selectSameDayPreviousYearAction
Name of the action to select the same day of year, previous year. |
static java.lang.String |
selectTodayAction
Name of the action to unselect all selected dates. |
protected java.util.TimeZone |
timeZone
The dates handled by a date component are always from a certain 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 java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
JDateComponent()
Creates a date component with a default date selection model. |
|
JDateComponent(DateSelectionModel model)
Creates a date component with a specified date selection model. |
|
| Method Summary | |
void |
addActionListener(java.awt.event.ActionListener listener)
Registers an action listener that is notified when some component specific action is performed. |
void |
addDateSelectionListener(DateSelectionListener listener)
Registers a date selection listener that will receive notifications when the date selection model changes. |
void |
fireActionEvent()
Notifies all registered listeners that an action happened on this component. |
protected void |
fireDateSelectionChanged(DateSelectionEvent evt)
|
protected void |
fireDisabledDatesChanged(DateSelectionEvent evt)
|
protected void |
fireDisabledDateSelectionAttempted(DateSelectionEvent evt)
|
protected void |
fireEmptySelectionAllowedChanged(DateSelectionEvent evt)
|
protected void |
fireSelectionModeChanged(DateSelectionEvent evt)
|
java.lang.String |
getActionCommand()
Returns the name of the action command that is used when an action event is created. |
java.util.Calendar |
getCalendar()
Returns the calendar object used by this component. |
DateSelectionModel |
getDateSelectionModel()
Returns the selection model used by this component. |
java.util.Locale |
getLocale()
Returns the locale used by this component. |
java.util.Date |
getSelectedDate()
Returns the currently selected date. |
java.util.TimeZone |
getTimeZone()
Returns the time zone used by this component. |
DateUI |
getUI()
Returns the L&F object that renders this component. |
boolean |
isEmptySelectionAllowed()
Determines whether empty selection is allowed. |
void |
removeActionListener(java.awt.event.ActionListener listener)
Removes a registered action listener. |
void |
removeDateSelectionListener(DateSelectionListener listener)
Removes a specified date selection listener. |
void |
setActionCommand(java.lang.String command)
Specifies the name of the action command that is used when an action event is created. |
void |
setDateSelectionModel(DateSelectionModel model)
Specifies a new selection model for this component. |
void |
setEmptySelectionAllowed(boolean allowed)
Specifies whether the model supports empty date selections that is no date can be selected at one time. |
void |
setLocale(java.util.Locale locale)
Specifies a new locale to be used by this component. |
void |
setSelectedDate(java.util.Date date)
Specifies the currently date selected by this component. |
void |
setTimeZone(java.util.TimeZone zone)
Specifies the time zone for this component. |
void |
setUI(DateUI ui)
Sets the L&F object that renders this component. |
void |
updateUI()
Notification from the UIManager that the L&F has
changed. |
| 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 DateSelectionModel dateSelectionModel
protected DateSelectionListener dateSelectionModelListener
protected java.lang.String actionCommand
protected java.util.Locale locale
protected java.util.Calendar calendar
protected java.util.TimeZone timeZone
public static final java.lang.String selectNoneAction
public static final java.lang.String selectTodayAction
public static final java.lang.String selectFirstDayAction
public static final java.lang.String selectLastDayAction
public static final java.lang.String selectNextDayAction
public static final java.lang.String selectPreviousDayAction
public static final java.lang.String selectSameDayNextWeekAction
public static final java.lang.String selectSameDayPreviousWeekAction
public static final java.lang.String selectSameDayNextMonthAction
public static final java.lang.String selectSameDayPreviousMonthAction
public static final java.lang.String selectSameDayNextYearAction
public static final java.lang.String selectSameDayPreviousYearAction
| Constructor Detail |
public JDateComponent()
public JDateComponent(DateSelectionModel model)
model - specified date selection model| Method Detail |
public java.util.Calendar getCalendar()
public java.util.Date getSelectedDate()
public void setSelectedDate(java.util.Date date)
date - new selected datepublic void addActionListener(java.awt.event.ActionListener listener)
listener - listener that is registeredpublic void removeActionListener(java.awt.event.ActionListener listener)
listener - listener that is removedpublic void setActionCommand(java.lang.String command)
command - name of the action commandpublic java.lang.String getActionCommand()
public void fireActionEvent()
Notifies all registered listeners that an action happened on this component. This method is especially used by the classes from this package and its subpackages and is not intended for public use.
Action events are a complementary mechanism for outside world notification. For instance, date selection events are fired as the date selection model changes but action events are fired when something happens with the component that cannot be notified somehow else. A calendar component would use an action event to notify a double click mouse event on a selectable date.
Because the action events are generic, one can differentiate between them using the name of the command. Each date component defines its own command names. Context information about the event is supplied by the component itself.
public DateUI getUI()
DateUI object that renders this componentpublic void setUI(DateUI ui)
ui - the DateUI L&F objectpublic void updateUI()
UIManager that the L&F has
changed. Replaces the current UI object with the latest version from
the UIManager.
JComponent.updateUI()public void addDateSelectionListener(DateSelectionListener listener)
listener - listener that is registeredsetDateSelectionModel(DateSelectionModel),
removeDateSelectionListener(DateSelectionListener)public void removeDateSelectionListener(DateSelectionListener listener)
listener - removed listenerpublic DateSelectionModel getDateSelectionModel()
public void setDateSelectionModel(DateSelectionModel model)
model - new selection model to be used by this componentpublic boolean isEmptySelectionAllowed()
true if empty selection is allowed or false otherwise.setEmptySelectionAllowed(boolean)
public void setEmptySelectionAllowed(boolean allowed)
throws DateSelectionException
true to false there must be at least
one date selected because otherwise the model would be in an inconsistent state.
If that does not happen, the operation fails throwing an exception.
allowed - true if empty selection is allowed or false otherwise
DateSelectionException - exception thrown when the model is set to not allow empty selections
but it does not contain any selected date.public java.util.Locale getLocale()
setLocale(Locale)public void setLocale(java.util.Locale locale)
locale - creates a specific configuration for this componentprotected void fireDisabledDatesChanged(DateSelectionEvent evt)
protected void fireDateSelectionChanged(DateSelectionEvent evt)
protected void fireSelectionModeChanged(DateSelectionEvent evt)
protected void fireEmptySelectionAllowedChanged(DateSelectionEvent evt)
protected void fireDisabledDateSelectionAttempted(DateSelectionEvent evt)
public java.util.TimeZone getTimeZone()
setTimeZone(TimeZone)public void setTimeZone(java.util.TimeZone zone)
Specifies the time zone for this component. This parameter is very important if you need to work with dates from another time zone than the default one. By default, the system's default time zone is used.
For instance, if your application is run by users across different time zones and they all work with GMT dates, then you should configure a date component to use the GMT time zone. If you don't do this, the component will use the system time zone which means local dates, not GMT.
zone - new time zone for this component
|
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.