JIDE 3.5.15

com.jidesoft.combobox
Class DateExComboBox

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JComboBox
                  extended by com.jidesoft.combobox.ExComboBox
                      extended by com.jidesoft.combobox.DateExComboBox
All Implemented Interfaces:
DateModelListener, ConverterContextSupport, ActionListener, ImageObserver, ItemSelectable, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, ListDataListener
Direct Known Subclasses:
MonthExComboBox

public class DateExComboBox
extends ExComboBox
implements DateModelListener

DateComboBox is a combobox which can be used to choose a Date.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jidesoft.combobox.ExComboBox
ExComboBox.LazyDelegateAction
 
Nested classes/interfaces inherited from class javax.swing.JComboBox
JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String PROPERTY_SHOW_NONE_BUTTON
           
static String PROPERTY_SHOW_OK_BUTTON
           
static String PROPERTY_SHOW_TODAY_BUTTON
           
static String PROPERTY_SHOW_WEEK_NUMBERS
           
 
Fields inherited from class com.jidesoft.combobox.ExComboBox
CLIENT_PROPERTY_HIDE_POPUP_ON_LIST_DATA_CHANGED, CLIENT_PROPERTY_POPUP_PANEL, CLIENT_PROPERTY_TABLE_CELL_EDITOR, CLIENT_PROPERTY_TABLE_CELL_RENDERER, COMMIT, COMMIT_OR_RESET, COMMIT_OR_REVERT, DIALOG, DOWN_KEY_BEHAVIOR_SELECT_NEXT, DOWN_KEY_BEHAVIOR_SHOW_POPUP, DROPDOWN, PERSIST, PROPERTY_BUTTON_VISIBLE, PROPERTY_SELECTED_ITEM, RESET, REVERT
 
Fields inherited from class javax.swing.JComboBox
actionCommand, dataModel, editor, isEditable, keySelectionManager, lightWeightPopupEnabled, maximumRowCount, renderer, selectedItemReminder
 
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
DateExComboBox()
          Constructs a new DateComboBox.
DateExComboBox(DateModel model)
          Constructs a new DateComboBox with specified DateModel.
 
Method Summary
 String convertElementToString(Object value, Class clazz)
           
 Object convertStringToElement(String text, Class clazz)
           
 Calendar createCalendarInstance()
          Creates a new Calendar instance that will be used internally.
protected  DateChooserPanel createDateChooserPanel()
          Creates a DateChooserPanel instance used by DateExComboBox.
 PopupPanel createPopupComponent()
          Creates the DateChoosrePanel.
 void customizePopup(JidePopup popup, PopupPanel panel)
          Customizes the popup and the popup panel before actually showing them.
 void dateModelChanged(DateModelEvent e)
          This notification tells listeners the something changed in date model.
protected  boolean equals(Object object1, Object object2)
          Check if object1 is equal to object2.
 Calendar getCalendar()
          Gets the Calendar object that is represented in this component.
 Date getDate()
          Gets the Date object that is represented in this component.
 DateModel getDateModel()
          Gets the DateModel.
 List<KeyStroke> getDelegateKeyStrokes()
          Overrides to undelegate CTRL+PAGE_UP and CTRL+PAGE_DOWN
 DateFormat getFormat()
          Gets the DateFormat that is used to renderer the label.
 String getTimeFormat()
          Gets the time format for time spinner on DateChooserPanel.
 boolean isInvalidValueAllowed()
          Checks if the invalid value is allowed.
 boolean isPopupVolatile()
          Checks if the popup is volatile.
 boolean isShowNoneButton()
          Checks if none button is visible.
 boolean isShowOKButton()
          Checks if OK button is visible.
 boolean isShowTodayButton()
          Checks if today button is visible.
 boolean isShowWeekNumbers()
          Checks if the week of year panel is visible.
 boolean isTimeDisplayed()
          Checks if the time is displayed.
 void setCalendar(Calendar calendar)
          Sets the Date.
 void setDate(Date date)
          Sets the Date.
 void setDateModel(DateModel dateModel)
          Sets the DateModel.
 void setFormat(DateFormat format)
          Sets the DateFormat.
 void setInvalidValueAllowed(boolean invalidValueAllowed)
          Sets the flag if the invalid value is allowed to be entered into DateComboBox.
 void setLocale(Locale l)
           
 void setSelectedItem(Object anObject, boolean fireEvent)
          Sets the selected item.
 void setSelectedItemWithoutValidation(Object anObject, boolean fireEvent)
          Sets the selected date.
 void setShowNoneButton(boolean showNoneButton)
          Sets the none button visible.
 void setShowOKButton(boolean showOKButton)
          Sets the OK button visible.
 void setShowTodayButton(boolean showTodayButton)
          Sets the today button visible.
 void setShowWeekNumbers(boolean showWeekNumbers)
          Sets the week of year panel visible.
 void setTimeDisplayed(boolean timeDisplayed)
          Sets the timeDisplayed property.
 void setTimeFormat(String timeFormat)
          Sets the format for the time spinner on DateChooserPanel.
protected  void updateDateFromEditorComponent()
           
 
Methods inherited from class com.jidesoft.combobox.ExComboBox
comboBoxSelected, commitEdit, commitEditWithFocusLostBehavior, convertElementToString, convertStringToElement, createButtonComponent, customizeDialog, customizeDialogLocation, customizeRendererComponent, delegateKeyStrokes, fireActionEvent, fireItemStateChanged, getActualUIClassID, getConverter, getConverterContext, getDefaultCancelAction, getDefaultOKAction, getDelegateTarget, getDialogCancelAction, getDialogOKAction, getDownKeyBehavior, getFocusLostBehavior, getPopupCancelBehavior, getPopupLocation, getPopupType, getSelectedItem, getType, getUIComboBoxEditorClassID, getUIComboBoxPopupClassID, getUIComboBoxRendererClassID, initComboBox, installColorFontAndBorder, isButtonOnly, isButtonVisible, isEmptyStringNull, isKeepPopupSize, isReallyFocusLost, isRetrievingValueFromPopup, isStretchToFit, isStretchToFitSet, isUpdateFromPopupOnFly, notifyUser, popupMenuCanceled, processKeyBinding, propertyChange, resetEdit, revertEdit, selectWithKeyChar, setButtonOnly, setButtonVisible, setConverter, setConverterContext, setDownKeyBehavior, setEditable, setEmptyStringNull, setFocusLostBehavior, setKeepPopupSize, setModel, setPopupCancelBehavior, setPopupLocation, setPopupType, setPopupVolatile, setSelectedItem, setStretchToFit, setType, undelegateKeyStrokes, updateUI, validateValueForNonEditable
 
Methods inherited from class javax.swing.JComboBox
actionPerformed, actionPropertyChanged, addActionListener, addItem, addItemListener, addPopupMenuListener, configureEditor, configurePropertiesFromAction, contentsChanged, createActionPropertyChangeListener, createDefaultKeySelectionManager, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getAction, getActionCommand, getActionListeners, getEditor, getItemAt, getItemCount, getItemListeners, getKeySelectionManager, getMaximumRowCount, getModel, getPopupMenuListeners, getPrototypeDisplayValue, getRenderer, getSelectedIndex, getSelectedObjects, getUI, getUIClassID, hidePopup, insertItemAt, installAncestorListener, intervalAdded, intervalRemoved, isEditable, isLightWeightPopupEnabled, isPopupVisible, paramString, processKeyEvent, removeActionListener, removeAllItems, removeItem, removeItemAt, removeItemListener, removePopupMenuListener, selectedItemChanged, setAction, setActionCommand, setEditor, setEnabled, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setPopupVisible, setPrototypeDisplayValue, setRenderer, setSelectedIndex, setUI, showPopup
 
Methods 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, 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
 
Methods 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, 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, 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, hide, 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, 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

PROPERTY_SHOW_NONE_BUTTON

public static final String PROPERTY_SHOW_NONE_BUTTON
See Also:
Constant Field Values

PROPERTY_SHOW_OK_BUTTON

public static final String PROPERTY_SHOW_OK_BUTTON
See Also:
Constant Field Values

PROPERTY_SHOW_TODAY_BUTTON

public static final String PROPERTY_SHOW_TODAY_BUTTON
See Also:
Constant Field Values

PROPERTY_SHOW_WEEK_NUMBERS

public static final String PROPERTY_SHOW_WEEK_NUMBERS
See Also:
Constant Field Values
Constructor Detail

DateExComboBox

public DateExComboBox()
Constructs a new DateComboBox.


DateExComboBox

public DateExComboBox(DateModel model)
Constructs a new DateComboBox with specified DateModel.

Parameters:
model - the DateModel.
Method Detail

getDateModel

public DateModel getDateModel()
Gets the DateModel.

Returns:
the DateModel.

setDateModel

public void setDateModel(DateModel dateModel)
Sets the DateModel.

Parameters:
dateModel - the date model

dateModelChanged

public void dateModelChanged(DateModelEvent e)
Description copied from interface: DateModelListener
This notification tells listeners the something changed in date model.

Specified by:
dateModelChanged in interface DateModelListener

createPopupComponent

public PopupPanel createPopupComponent()
Creates the DateChoosrePanel. Here is the code we used to create it. You can override to if you want to subclass DateChooserPanel in order to override methods on DateChooserPanel.

 DateChooserPanel dateChooserPanel = new DateChooserPanel(getDateModel(),
 isShowTodayButton(),
 isShowNoneButton(), isShowWeekNumbers(), getLocale());
 dateChooserPanel.setTimeDisplayed(isTimeDisplayed());
 dateChooserPanel.setShowOKButton(isShowOKButton());
 return dateChooserPanel;
 

Specified by:
createPopupComponent in class ExComboBox
Returns:
an instance of DateChooserPanel.

createDateChooserPanel

protected DateChooserPanel createDateChooserPanel()
Creates a DateChooserPanel instance used by DateExComboBox.

Returns:
an instance of DateChooserPanel.
Since:
3.3.3

isPopupVolatile

public boolean isPopupVolatile()
Description copied from class: ExComboBox
Checks if the popup is volatile. If a popup is volatile, it will be recreated every time the popup is shown. By default, it's false. Subclasses can override it to return true or false depending on the actual case.

Overrides:
isPopupVolatile in class ExComboBox
Returns:
true if the popup is volatile.

getDate

public Date getDate()
Gets the Date object that is represented in this component.

Returns:
the Date

setSelectedItemWithoutValidation

public void setSelectedItemWithoutValidation(Object anObject,
                                             boolean fireEvent)
Sets the selected date. This method will not validate the date like setSelectedItem(Object,boolean) does.

Parameters:
anObject - the new date
fireEvent - true to fire event. False to not to fire event.

equals

protected boolean equals(Object object1,
                         Object object2)
Description copied from class: ExComboBox
Check if object1 is equal to object2. The default implementation is check if the object1 and object2 is the same instance. You can override it if you need more concise control on the events.

Overrides:
equals in class ExComboBox
Parameters:
object1 - one of the two objects
object2 - another one of the two objects
Returns:
true if those two objects are equal. Otherwise false.

setSelectedItem

public void setSelectedItem(Object anObject,
                            boolean fireEvent)
Sets the selected item. This method will valid to make sure the new value is a valid date using getDateModel.isValidDate method.

Overrides:
setSelectedItem in class ExComboBox
Parameters:
anObject - the new date
fireEvent - true to fire event. False to not to fire event.

createCalendarInstance

public Calendar createCalendarInstance()
Creates a new Calendar instance that will be used internally.

Returns:
a Calendar instance.

updateDateFromEditorComponent

protected void updateDateFromEditorComponent()

getCalendar

public Calendar getCalendar()
Gets the Calendar object that is represented in this component.

Returns:
the Date in Calendar

setDate

public void setDate(Date date)
Sets the Date.

Parameters:
date - the date

setCalendar

public void setCalendar(Calendar calendar)
Sets the Date.

Parameters:
calendar - the calendar

convertElementToString

public String convertElementToString(Object value,
                                     Class clazz)
Overrides:
convertElementToString in class ExComboBox

convertStringToElement

public Object convertStringToElement(String text,
                                     Class clazz)
Overrides:
convertStringToElement in class ExComboBox

getFormat

public DateFormat getFormat()
Gets the DateFormat that is used to renderer the label.

Returns:
the DateFormat

setFormat

public void setFormat(DateFormat format)
Sets the DateFormat.

Please note, if you want to change the DateFormat, please make sure you call this method before you set the Calendar value using setCalendar(java.util.Calendar) method. Otherwise, the Calendar value you set will be converted using the old format. Here is the right order to display time value in DateComboBox.

 DateComboBox dateBox = new DateComboBox();
 dateBox.setTimeDisplayed(true);
 dateBox.setFormat(DateFormat.getDateTimeInstance()); // call this before setCalendar.
 dateBox.setCalendar(cal);
 

Parameters:
format - the date format

isShowTodayButton

public boolean isShowTodayButton()
Checks if today button is visible.

Returns:
true if today button is visible.

setShowTodayButton

public void setShowTodayButton(boolean showTodayButton)
Sets the today button visible.

Parameters:
showTodayButton - the flag

isShowNoneButton

public boolean isShowNoneButton()
Checks if none button is visible.

Returns:
true if none button is visible.

setShowNoneButton

public void setShowNoneButton(boolean showNoneButton)
Sets the none button visible.

Parameters:
showNoneButton - the flag

isShowOKButton

public boolean isShowOKButton()
Checks if OK button is visible.

Returns:
true if OK button is visible.

setShowOKButton

public void setShowOKButton(boolean showOKButton)
Sets the OK button visible. Even you set it to true, OK button will only be displayed when setTimeDisplayed(boolean) is also set to true.

Parameters:
showOKButton - the flag

isShowWeekNumbers

public boolean isShowWeekNumbers()
Checks if the week of year panel is visible.

Returns:
true if the week of year is visible.

setShowWeekNumbers

public void setShowWeekNumbers(boolean showWeekNumbers)
Sets the week of year panel visible.

Parameters:
showWeekNumbers - the flag

getDelegateKeyStrokes

public List<KeyStroke> getDelegateKeyStrokes()
Overrides to undelegate CTRL+PAGE_UP and CTRL+PAGE_DOWN

Overrides:
getDelegateKeyStrokes in class ExComboBox
Returns:
the list of KeyStrokes that will be delegated to the popup panel.

isTimeDisplayed

public boolean isTimeDisplayed()
Checks if the time is displayed.

Returns:
true or false.

setTimeDisplayed

public void setTimeDisplayed(boolean timeDisplayed)
Sets the timeDisplayed property. If this property is true, the DateChooserPanel will show a time spinner so that user can change time.

Parameters:
timeDisplayed - the flag

getTimeFormat

public String getTimeFormat()
Gets the time format for time spinner on DateChooserPanel.

Returns:
the time format.

setTimeFormat

public void setTimeFormat(String timeFormat)
Sets the format for the time spinner on DateChooserPanel. The default value is "hh:mm a". Please refer to SimpleDateFormat for the specification of format. Please also note this time format is not for what to be displayed in the combobox itself. The format that controls what is displayed in the combobox is setFormat(java.text.DateFormat).

Parameters:
timeFormat - the flag

customizePopup

public void customizePopup(JidePopup popup,
                           PopupPanel panel)
Description copied from class: ExComboBox
Customizes the popup and the popup panel before actually showing them.

By default, it's an empty implementation.

Overrides:
customizePopup in class ExComboBox
Parameters:
popup - the JidePopup
panel - the popup panel

setLocale

public void setLocale(Locale l)
Overrides:
setLocale in class Component

isInvalidValueAllowed

public boolean isInvalidValueAllowed()
Checks if the invalid value is allowed.

Returns:
true or false.

setInvalidValueAllowed

public void setInvalidValueAllowed(boolean invalidValueAllowed)
Sets the flag if the invalid value is allowed to be entered into DateComboBox. If false (the default value), user must type a valid date string in the correct format. Otherwise, the focus lost or after enter is pressed, the invalid value will be reset. If true, the invalid string will be kept and set to the combobox using setSelectedItem. Developer can use getSelectedItem to retrieve the value. getDate or getCalendar will still return null as the value is not valid.

Parameters:
invalidValueAllowed - true or false.

JIDE 3.5.15