Overview | Package | Class | Use | Deprecated | Help
| GWT 2.7.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.gwt.user.datepicker.client
Class DatePicker

    java.lang.Object
      com.google.gwt.user.client.ui.UIObject
          com.google.gwt.user.client.ui.Widget
              com.google.gwt.user.client.ui.Composite
                  com.google.gwt.user.datepicker.client.DatePicker

All Implemented Interfaces:
  IsEditor<LeafValueEditor<java.util.Date>>, HasAttachHandlers, HasHighlightHandlers<java.util.Date>, HasShowRangeHandlers<java.util.Date>, HasValueChangeHandlers<java.util.Date>, HasHandlers, EventListener, TakesValue<java.util.Date>, HasValue<java.util.Date>, HasVisibility, IsRenderable, IsWidget

    public class DatePicker

extends Composite
implements HasHighlightHandlers<java.util.Date>, HasShowRangeHandlers<java.util.Date>, HasValue<java.util.Date>, IsEditor<LeafValueEditor<java.util.Date>>

Standard GWT date picker.

### CSS Style Rules

- .gwt-DatePicker { }
- .datePickerMonthSelector { the month selector widget }
- .datePickerMonth { the month in the month selector widget }
- .datePickerYear { the year in the month selector widget }
- .datePickerPreviousButton { the previous month button }
- .datePickerNextButton { the next month button }
- .datePickerPreviousYearButton { the previous year button }
- .datePickerNextYearButton { the next year button }
- .datePickerDays { the portion of the picker that shows the days }
- .datePickerWeekdayLabel { the label over weekdays }
- .datePickerWeekendLabel { the label over weekends }
- .datePickerDay { a single day }
- .datePickerDayIsToday { today's date }
- .datePickerDayIsWeekend { a weekend day }
- .datePickerDayIsFiller { a day in another month }
- .datePickerDayIsValue { the selected day }
- .datePickerDayIsDisabled { a disabled day }
- .datePickerDayIsHighlighted { the currently highlighted day }
- .datePickerDayIsValueAndHighlighted { the highlighted day if it is also selected }

### Example

>     public class DatePickerExample implements EntryPoint {

>       public void onModuleLoad() {
>         // Create a date picker
>         DatePicker datePicker = new DatePicker();
>         final Label text = new Label();

>         // Set the value in the text box when the user selects a date
>         datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
>           public void onValueChange(ValueChangeEvent<Date> event) {
>             Date date = event.getValue();
>             String dateString = DateTimeFormat.getMediumDateFormat().format(date);
>             text.setText(dateString);
>           }
>         });

>         // Set the default value
>         datePicker.setValue(new Date(), true);

>         // Add the widgets to the page
>         RootPanel.get().add(text);
>         RootPanel.get().add(datePicker);
>       }
>     }

Nested Class Summary
`(package private) static class` | `DatePicker.StandardCss` Convenience class to group css style names.

Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
`UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled`

Field Summary

Fields inherited from class com.google.gwt.user.client.ui.UIObject
`DEBUG_ID_PREFIX`

Constructor Summary
`` | `DatePicker()` Create a new date picker.
`protected` | `DatePicker(MonthSelector monthAndYearSelector, CalendarView view, CalendarModel model)` Creates a new date picker.

Method Summary
`HandlerRegistration` | `addHighlightHandler(HighlightHandler<java.util.Date> handler)` Adds a `HighlightEvent` handler.
`HandlerRegistration` | `addShowRangeHandler(ShowRangeHandler<java.util.Date> handler)` Adds a `ShowRangeEvent` handler.
`HandlerRegistration` | `addShowRangeHandlerAndFire(ShowRangeHandler<java.util.Date> handler)` Adds a show range handler and immediately activate the handler on the current view.
`void` | `addStyleToDates(java.lang.String styleName, java.util.Date date)` Add a style name to the given dates.
`void` | `addStyleToDates(java.lang.String styleName, java.util.Date date, java.util.Date... moreDates)` Add a style name to the given dates.
`void` | `addStyleToDates(java.lang.String styleName, java.lang.Iterable<java.util.Date> dates)` Add a style name to the given dates.
`void` | `addTransientStyleToDates(java.lang.String styleName, java.util.Date date)` Adds the given style name to the specified dates, which must be visible.
`void` | `addTransientStyleToDates(java.lang.String styleName, java.util.Date date, java.util.Date... moreDates)` Adds the given style name to the specified dates, which must be visible.
`void` | `addTransientStyleToDates(java.lang.String styleName, java.lang.Iterable<java.util.Date> dates)` Adds the given style name to the specified dates, which must be visible.
`HandlerRegistration` | `addValueChangeHandler(ValueChangeHandler<java.util.Date> handler)` Adds a `ValueChangeEvent` handler.
`LeafValueEditor<java.util.Date>` | `asEditor()` Returns a `TakesValueEditor` backed by the DatePicker.
`(package private) DatePicker.StandardCss` | `css()` Gets the css associated with this date picker for use by extended month and cell grids.
`java.util.Date` | `getCurrentMonth()` Gets the current month the date picker is showing.
`java.util.Date` | `getFirstDate()` Returns the first shown date.
`java.util.Date` | `getHighlightedDate()` Gets the highlighted date (the one the mouse is hovering over), if any.
`java.util.Date` | `getLastDate()` Returns the last shown date.
`protected CalendarModel` | `getModel()` Gets the `CalendarModel` associated with this date picker.
`protected MonthSelector` | `getMonthSelector()` Gets the `MonthSelector` associated with this date picker.
`java.lang.String` | `getStyleOfDate(java.util.Date date)` Gets the style associated with a date (does not include styles set via `addTransientStyleToDates(java.lang.String, java.util.Date)`).
`java.util.Date` | `getValue()` Returns the selected date, or null if none is selected.
`protected CalendarView` | `getView()` Gets the `CalendarView` associated with this date picker.
`int` | `getVisibleYearCount()` Returns the number of year to display in the years selection dropdown.
`boolean` | `isDateEnabled(java.util.Date date)` Is the visible date enabled?
`boolean` | `isDateVisible(java.util.Date date)` Is the date currently shown in the date picker?
`boolean` | `isYearAndMonthDropdownVisible()` Is the year and month selectable via a dropdown?
`boolean` | `isYearArrowsVisible()` Can the user navigate through the years?
`void` | `onLoad()` This method is called immediately after a widget becomes attached to the browser's document.
`protected void` | `refreshAll()` Refreshes all components of this date picker.
`void` | `removeStyleFromDates(java.lang.String styleName, java.util.Date date)` Removes the styleName from the given dates (even if it is transient).
`void` | `removeStyleFromDates(java.lang.String styleName, java.util.Date date, java.util.Date... moreDates)` Removes the styleName from the given dates (even if it is transient).
`void` | `removeStyleFromDates(java.lang.String styleName, java.lang.Iterable<java.util.Date> dates)` Removes the styleName from the given dates (even if it is transient).
`void` | `setCurrentMonth(java.util.Date month)` Sets the date picker to show the given month, use `getFirstDate()` and `getLastDate()` to access the exact date range the date picker chose to display.
`(package private) void` | `setHighlightedDate(java.util.Date highlighted)` Sets the highlighted date.
`void` | `setStyleName(java.lang.String styleName)` Sets the date picker style name.
`void` | `setTransientEnabledOnDates(boolean enabled, java.util.Date date)` Sets a visible date to be enabled or disabled.
`void` | `setTransientEnabledOnDates(boolean enabled, java.util.Date date, java.util.Date... moreDates)` Sets a visible date to be enabled or disabled.
`void` | `setTransientEnabledOnDates(boolean enabled, java.lang.Iterable<java.util.Date> dates)` Sets a group of visible dates to be enabled or disabled.
`protected void` | `setup()` Sets up the date picker.
`void` | `setValue(java.util.Date newValue)` Sets the `DatePicker`'s value.
`void` | `setValue(java.util.Date newValue, boolean fireEvents)` Sets the `DatePicker`'s value.
`void` | `setVisibleYearCount(int numberOfYears)` Set the number of years to display in the years selection dropdown.
`void` | `setYearAndMonthDropdownVisible(boolean dropdownVisible)` If the `dropdownVisible` is equal to true, the user will be able to change the current month and the current year of the date picker via two dropdown lists.
`void` | `setYearArrowsVisible(boolean yearArrowsVisible)` Set if the user can navigate through the years via a set of backward and forward buttons.

Methods inherited from class com.google.gwt.user.client.ui.Composite
`claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget`

Methods inherited from class com.google.gwt.user.client.ui.Widget
`addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents`

Methods inherited from class com.google.gwt.user.client.ui.UIObject
`addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Constructor Detail

### DatePicker

    public DatePicker()

  Create a new date picker.

### DatePicker

    protected DatePicker(MonthSelector monthAndYearSelector,
                         CalendarView view,
                         CalendarModel model)

  Creates a new date picker.

  Parameters:
    `monthAndYearSelector` - the month selector
    `view` - the view
    `model` - the model

Method Detail

### addHighlightHandler

    public HandlerRegistration addHighlightHandler(HighlightHandler<java.util.Date> handler)

  Description copied from interface: `HasHighlightHandlers`
  Adds a `HighlightEvent` handler.

  Specified by:
    `addHighlightHandler` in interface `HasHighlightHandlers<java.util.Date>`
  Parameters:
    `handler` - the handler
  Returns:
    the registration for the event

### addShowRangeHandler

    public HandlerRegistration addShowRangeHandler(ShowRangeHandler<java.util.Date> handler)

  Description copied from interface: `HasShowRangeHandlers`
  Adds a `ShowRangeEvent` handler.

  Specified by:
    `addShowRangeHandler` in interface `HasShowRangeHandlers<java.util.Date>`
  Parameters:
    `handler` - the handler
  Returns:
    the registration for the event

### addShowRangeHandlerAndFire

    public HandlerRegistration addShowRangeHandlerAndFire(ShowRangeHandler<java.util.Date> handler)

  Adds a show range handler and immediately activate the handler on the current view.

  Parameters:
    `handler` - the handler
  Returns:
    the handler registration

### addStyleToDates

    public void addStyleToDates(java.lang.String styleName,
                                java.util.Date date)

  Add a style name to the given dates.

### addStyleToDates

    public void addStyleToDates(java.lang.String styleName,
                                java.util.Date date,
                                java.util.Date... moreDates)

  Add a style name to the given dates.

### addStyleToDates

    public void addStyleToDates(java.lang.String styleName,
                                java.lang.Iterable<java.util.Date> dates)

  Add a style name to the given dates.

### addTransientStyleToDates

    public void addTransientStyleToDates(java.lang.String styleName,
                                         java.util.Date date)

  Adds the given style name to the specified dates, which must be visible. This is only set until the next time the DatePicker is refreshed.

### addTransientStyleToDates

    public final void addTransientStyleToDates(java.lang.String styleName,
                                               java.util.Date date,
                                               java.util.Date... moreDates)

  Adds the given style name to the specified dates, which must be visible. This is only set until the next time the DatePicker is refreshed.

### addTransientStyleToDates

    public final void addTransientStyleToDates(java.lang.String styleName,
                                               java.lang.Iterable<java.util.Date> dates)

  Adds the given style name to the specified dates, which must be visible. This is only set until the next time the DatePicker is refreshed.

### addValueChangeHandler

    public HandlerRegistration addValueChangeHandler(ValueChangeHandler<java.util.Date> handler)

  Description copied from interface: `HasValueChangeHandlers`
  Adds a `ValueChangeEvent` handler.

  Specified by:
    `addValueChangeHandler` in interface `HasValueChangeHandlers<java.util.Date>`
  Parameters:
    `handler` - the handler
  Returns:
    the registration for the event

### asEditor

    public LeafValueEditor<java.util.Date> asEditor()

  Returns a `TakesValueEditor` backed by the DatePicker.

  Specified by:
    `asEditor` in interface `IsEditor<LeafValueEditor<java.util.Date>>`
  Returns:
    an `Editor` of type E

### getCurrentMonth

    public java.util.Date getCurrentMonth()

  Gets the current month the date picker is showing.

  A datepicker may show days not in the current month. It must show all days in the current month.

  Returns:
    the current month

### getFirstDate

    public final java.util.Date getFirstDate()

  Returns the first shown date.

  Returns:
    the first date.

### getHighlightedDate

    public final java.util.Date getHighlightedDate()

  Gets the highlighted date (the one the mouse is hovering over), if any.

  Returns:
    the highlighted date

### getLastDate

    public final java.util.Date getLastDate()

  Returns the last shown date.

  Returns:
    the last date.

### getVisibleYearCount

    public int getVisibleYearCount()

  Returns the number of year to display in the years selection dropdown.

### getStyleOfDate

    public java.lang.String getStyleOfDate(java.util.Date date)

  Gets the style associated with a date (does not include styles set via `addTransientStyleToDates(java.lang.String, java.util.Date)`).

  Parameters:
    `date` - the date
  Returns:
    the styles associated with this date

### getValue

    public final java.util.Date getValue()

  Returns the selected date, or null if none is selected.

  Specified by:
    `getValue` in interface `TakesValue<java.util.Date>`
  Specified by:
    `getValue` in interface `HasValue<java.util.Date>`
  Returns:
    the selected date, or null
  See Also:
    `TakesValue.setValue(V)`

### isDateEnabled

    public boolean isDateEnabled(java.util.Date date)

  Is the visible date enabled?

  Parameters:
    `date` - the date, which must be visible
  Returns:
    is the date enabled?

### isDateVisible

    public boolean isDateVisible(java.util.Date date)

  Is the date currently shown in the date picker?

  Parameters:
    `date` -
  Returns:
    is the date currently shown

### isYearArrowsVisible

    public boolean isYearArrowsVisible()

  Can the user navigate through the years?

  Returns:
    is the year navigation is enabled

### isYearAndMonthDropdownVisible

    public boolean isYearAndMonthDropdownVisible()

  Is the year and month selectable via a dropdown?

### onLoad

    public void onLoad()

  Description copied from class: `Widget`
  This method is called immediately after a widget becomes attached to the browser's document.

  Overrides:
    `onLoad` in class `Widget`

### removeStyleFromDates

    public void removeStyleFromDates(java.lang.String styleName,
                                     java.util.Date date)

  Removes the styleName from the given dates (even if it is transient).

### removeStyleFromDates

    public void removeStyleFromDates(java.lang.String styleName,
                                     java.util.Date date,
                                     java.util.Date... moreDates)

  Removes the styleName from the given dates (even if it is transient).

### removeStyleFromDates

    public void removeStyleFromDates(java.lang.String styleName,
                                     java.lang.Iterable<java.util.Date> dates)

  Removes the styleName from the given dates (even if it is transient).

### setCurrentMonth

    public void setCurrentMonth(java.util.Date month)

  Sets the date picker to show the given month, use `getFirstDate()` and `getLastDate()` to access the exact date range the date picker chose to display.

  A datepicker may show days not in the current month. It must show all days in the current month.

  Parameters:
    `month` - the month to show

### setVisibleYearCount

    public void setVisibleYearCount(int numberOfYears)

  Set the number of years to display in the years selection dropdown. The range of years will be centered on the selected date.

### setYearArrowsVisible

    public void setYearArrowsVisible(boolean yearArrowsVisible)

  Set if the user can navigate through the years via a set of backward and forward buttons.

### setYearAndMonthDropdownVisible

    public void setYearAndMonthDropdownVisible(boolean dropdownVisible)

  If the `dropdownVisible` is equal to true, the user will be able to change the current month and the current year of the date picker via two dropdown lists.

### setStyleName

    public void setStyleName(java.lang.String styleName)

  Sets the date picker style name.

  Overrides:
    `setStyleName` in class `UIObject`
  Parameters:
    `styleName` - the new style name
  See Also:
    `UIObject.setStylePrimaryName(String)`

### setTransientEnabledOnDates

    public final void setTransientEnabledOnDates(boolean enabled,
                                                 java.util.Date date)

  Sets a visible date to be enabled or disabled. This is only set until the next time the DatePicker is refreshed.

### setTransientEnabledOnDates

    public final void setTransientEnabledOnDates(boolean enabled,
                                                 java.util.Date date,
                                                 java.util.Date... moreDates)

  Sets a visible date to be enabled or disabled. This is only set until the next time the DatePicker is refreshed.

### setTransientEnabledOnDates

    public final void setTransientEnabledOnDates(boolean enabled,
                                                 java.lang.Iterable<java.util.Date> dates)

  Sets a group of visible dates to be enabled or disabled. This is only set until the next time the DatePicker is refreshed.

### setValue

    public final void setValue(java.util.Date newValue)

  Sets the `DatePicker`'s value.

  Specified by:
    `setValue` in interface `TakesValue<java.util.Date>`
  Specified by:
    `setValue` in interface `HasValue<java.util.Date>`
  Parameters:
    `newValue` - the new value
  See Also:
    `TakesValue.getValue()`

### setValue

    public final void setValue(java.util.Date newValue,
                               boolean fireEvents)

  Sets the `DatePicker`'s value.

  Specified by:
    `setValue` in interface `HasValue<java.util.Date>`
  Parameters:
    `newValue` - the new value for this date picker
    `fireEvents` - should events be fired.

### getModel

    protected final CalendarModel getModel()

  Gets the `CalendarModel` associated with this date picker.

  Returns:
    the model

### getMonthSelector

    protected final MonthSelector getMonthSelector()

  Gets the `MonthSelector` associated with this date picker.

  Returns:
    the month selector

### getView

    protected final CalendarView getView()

  Gets the `CalendarView` associated with this date picker.

  Returns:
    the view

### refreshAll

    protected final void refreshAll()

  Refreshes all components of this date picker.

### setup

    protected void setup()

  Sets up the date picker.

### css

    final DatePicker.StandardCss css()

  Gets the css associated with this date picker for use by extended month and cell grids.

  Returns:
    the css.

### setHighlightedDate

    void setHighlightedDate(java.util.Date highlighted)

  Sets the highlighted date.

  Parameters:
    `highlighted` - highlighted date

Overview | Package | Class | Use | Deprecated | Help
| GWT 2.7.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD