JDatePicker v4.3

com.standbysoft.component.date.swing.plaf.basic
Class AbstractDatePickerUI

java.lang.Object
  extended byjavax.swing.plaf.ComponentUI
      extended bycom.standbysoft.component.date.swing.plaf.DateUI
          extended bycom.standbysoft.component.date.swing.plaf.basic.AbstractDatePickerUI
Direct Known Subclasses:
BasicDatePickerUI

public abstract class AbstractDatePickerUI
extends DateUI

Defines the general structure that is used by subclasses to implement the actual UI delegate for JDatePicker. It uses a simple combo box and a calendar to select/edit a date.

This UI delegate can be configured using two client properties:

JDatePicker.backgroundOnEditable fixes a JComboBox implementation bug. This UI delegate uses a JComboBox to represent the date picker. But the combo box does not set the background color correctly when made editable. So, we use this property to correct that. When this property is configured with the Boolean.TRUE value, the combo box background is also set on its editor component. By default, this property is not set.

 	JDatePicker datePicker = new JDatePicker();
 	datePicker.setEditable(true);
 	datePicker.putClientProperty("JDatePicker.backgroundOnEditable", Boolean.TRUE);
 

JDateEditComponent.clearOnEdit configures the editing behavior when the date picker is editable. If this property is set to Boolean.TRUE, the date is cleared when the user initiates an edit with the keyboard. But, if the user initiates an edit by clicking in the field with the mouse, the date is NOT cleared and the cursor is placed exactly where the user clicked. By default, this property is not set.

 	JDatePicker datePicker = new JDatePicker();
 	datePicker.setEditable(true);
 	datePicker.putClientProperty("JDateEditComponent.clearOnEdit", Boolean.TRUE);
 

See Also:
How to Configure UI Delegates, BasicDatePickerUI

Field Summary
protected  JComboBoxExt comboBox
          Combo box used to create the date picker.
protected  JDatePicker datePicker
          Component for which this UI is registered.
protected  JMonthView monthView
          Calendar component used with the combo box to select dates.
 
Constructor Summary
AbstractDatePickerUI()
           
 
Method Summary
protected abstract  JComboBoxExt createComboBox()
          Creates the combo box that is used by the date picker to select a date.
protected  java.lang.Object[] createDefaults()
          Creates a list of default values for some of the properties of JDatePicker.
protected abstract  java.awt.LayoutManager createLayout()
          Creates a LayoutManager that manages the combo box used to select/edit the date.
protected abstract  JMonthView createMonthView()
          Creates the calendar component that will be used by JDatePicker to select a date.
protected  java.beans.PropertyChangeListener createPropertyChangeListener()
          Creates a PropertyChangeListener that keeps track of the changes in the JDatePicker component.
protected  void initializeDefaults()
          Registers the default values created for some of the properties of JDatePicker with the UIManager.
protected  void installComponents()
          Installs all the components needed by JDatePicker to implement its behavior.
protected  void installDefaults()
          Installs the default font and colors on the JDatePicker component.
protected  void installKeyboardActions()
           
protected  void installListeners()
          Creates and installs the listeners for the date picker.
 void installUI(javax.swing.JComponent c)
          Registers all the UI stuff needed to make the specified component work.
 boolean isPopupVisible(JDatePicker c)
           
static void registerDateComboBoxUI(java.lang.String lf, java.lang.Class ui)
          Registers a ComboBoxUI object that also implements ComboBoxUIExt for a specified look and feel.
 void setPopupVisible(JDatePicker c, boolean v)
           
protected  void uninstallComponents()
           
protected  void uninstallDefaults()
           
protected  void uninstallKeyboardActions()
           
protected  void uninstallListeners()
          Uninstalls the listeners from the date field.
 void uninstallUI(javax.swing.JComponent c)
           
static void unregisterDateComboBoxUI(java.lang.String lf)
          Unregisters the ComboBoxUI object that also implements ComboBoxUIExt for a specified look and feel.
protected abstract  void updateBackground()
          Updates the background color for the supporting combo box.
protected abstract  void updateDateFormat()
           
protected abstract  void updateDateSelectionModel()
          Updates the selection model for the components of the date picker
protected abstract  void updateEditable()
          Updates the editable state of the date picker components.
protected abstract  void updateEnabled()
          Updates the enabled state of the children Components based on the enabled state of the JDatePicker.
protected abstract  void updateFont()
          Updates the font for the date picker components.
protected abstract  void updateForeground()
          Updates the foreground color for the supporting combo box.
protected abstract  void updateLocale()
          Updates the locale for the date picker components.
protected abstract  void updateTimeZone()
          Updates the time zone of the date picker component.
protected abstract  void updateToolTipText()
          Updates the tooltip text for the date picker component.
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, getPreferredSize, paint, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

datePicker

protected JDatePicker datePicker
Component for which this UI is registered.


comboBox

protected JComboBoxExt comboBox
Combo box used to create the date picker.


monthView

protected JMonthView monthView
Calendar component used with the combo box to select dates.

Constructor Detail

AbstractDatePickerUI

public AbstractDatePickerUI()
Method Detail

createDefaults

protected java.lang.Object[] createDefaults()

Creates a list of default values for some of the properties of JDatePicker. These values are instances of objects that implement the UIResource interface. For instance, default fonts are created using the FontUIResource class while colors using the ColorUIResource class.

The list is structured as follows: [key1, value1, key2, value2, ...] where the keys identify the properties and the values indicate the default values for these properties.

The keys returned in the list by this method are:

  1. DatePicker.font
  2. DatePicker.foreground
  3. DatePicker.background
    1. Returns:
      a list of default values for some of the properties of JDatePicker
      See Also:
      initializeDefaults(), installDefaults()

initializeDefaults

protected void initializeDefaults()

Registers the default values created for some of the properties of JDatePicker with the UIManager.

See Also:
installDefaults()

installUI

public void installUI(javax.swing.JComponent c)
Registers all the UI stuff needed to make the specified component work. In other words, this is the place where the component's look and feel is created.

See Also:
installDefaults(), installComponents(), installListeners(), installKeyboardActions()

installDefaults

protected void installDefaults()
Installs the default font and colors on the JDatePicker component.


installComponents

protected void installComponents()

Installs all the components needed by JDatePicker to implement its behavior.

See Also:
createLayout(), createMonthView(), createComboBox()

createLayout

protected abstract java.awt.LayoutManager createLayout()
Creates a LayoutManager that manages the combo box used to select/edit the date.

Returns:
a LayoutManager for the date picker.

createMonthView

protected abstract JMonthView createMonthView()

Creates the calendar component that will be used by JDatePicker to select a date. If you want to provide your own JMonthView instance, keep in mind that its instance will be used by this delegate so all operations should pass through the JDatePicker interface methods.

Returns:
a calendar that will be used by the date picker to select dates.

createComboBox

protected abstract JComboBoxExt createComboBox()
Creates the combo box that is used by the date picker to select a date.

Returns:
actual combo box.

installListeners

protected void installListeners()
Creates and installs the listeners for the date picker. This method is called when the UI is installed.


createPropertyChangeListener

protected java.beans.PropertyChangeListener createPropertyChangeListener()
Creates a PropertyChangeListener that keeps track of the changes in the JDatePicker component. If this method returns null then it will not be added to the date field.

Returns:
an instance PropertyChangeListener or null.

installKeyboardActions

protected void installKeyboardActions()

uninstallUI

public void uninstallUI(javax.swing.JComponent c)

uninstallDefaults

protected void uninstallDefaults()

uninstallComponents

protected void uninstallComponents()

uninstallKeyboardActions

protected void uninstallKeyboardActions()

uninstallListeners

protected void uninstallListeners()
Uninstalls the listeners from the date field. This method is called when the UI is uninstalled.


setPopupVisible

public void setPopupVisible(JDatePicker c,
                            boolean v)

isPopupVisible

public boolean isPopupVisible(JDatePicker c)

updateEnabled

protected abstract void updateEnabled()
Updates the enabled state of the children Components based on the enabled state of the JDatePicker.


updateFont

protected abstract void updateFont()
Updates the font for the date picker components.


updateDateSelectionModel

protected abstract void updateDateSelectionModel()
Updates the selection model for the components of the date picker


updateLocale

protected abstract void updateLocale()
Updates the locale for the date picker components.


updateEditable

protected abstract void updateEditable()
Updates the editable state of the date picker components.


updateTimeZone

protected abstract void updateTimeZone()
Updates the time zone of the date picker component.


updateToolTipText

protected abstract void updateToolTipText()
Updates the tooltip text for the date picker component.


updateForeground

protected abstract void updateForeground()
Updates the foreground color for the supporting combo box.


updateBackground

protected abstract void updateBackground()
Updates the background color for the supporting combo box.


updateDateFormat

protected abstract void updateDateFormat()

registerDateComboBoxUI

public static void registerDateComboBoxUI(java.lang.String lf,
                                          java.lang.Class ui)
Registers a ComboBoxUI object that also implements ComboBoxUIExt for a specified look and feel. The UI will be used by the date combobox to display the calendar.

Parameters:
lf - look and feel for which the ui is registered, com.sun.java.swing.plaf.motif.MotifLookAndFeel for instance
ui - ComboBoxUI object associated with the look and feel

unregisterDateComboBoxUI

public static void unregisterDateComboBoxUI(java.lang.String lf)
Unregisters the ComboBoxUI object that also implements ComboBoxUIExt for a specified look and feel.

Parameters:
lf - look and feel for which the ui is registered, com.sun.java.swing.plaf.motif.MotifLookAndFeel for instance

JDatePicker v4.3

Visit www.jdatepicker.com for further information or send us your suggestions.

Copyright © 2003-2007 Stand By Soft Ltd. All Rights Reserved.