public class

DatePicker

extends Composite
implements IsEditor<E extends Editor<?>> HasHighlightHandlers<V> HasShowRangeHandlers<V> HasValue<T>
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

Class Overview

Standard GWT date picker.

CSS Style Rules

  • .gwt-DatePicker { }
  • .datePickerMonthSelector { the month selector widget }
  • .datePickerMonth { the month in the month selector widget }
  • .datePickerPreviousButton { the previous month button }
  • .datePickerNextButton { the next month 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

{@example com.google.gwt.examples.DatePickerExample}

Summary

[Expand]
Inherited Constants
From class com.google.gwt.user.client.ui.UIObject
Public Constructors
DatePicker()
Create a new date picker.
Protected Constructors
DatePicker(MonthSelector monthSelector, CalendarView view, CalendarModel model)
Creates a new date picker.
Public Methods
HandlerRegistration addHighlightHandler(HighlightHandler<Date> handler)
HandlerRegistration addShowRangeHandler(ShowRangeHandler<Date> handler)
HandlerRegistration addShowRangeHandlerAndFire(ShowRangeHandler<Date> handler)
Adds a show range handler and immediately activate the handler on the current view.
void addStyleToDates(String styleName, Iterable<Date> dates)
Add a style name to the given dates.
void addStyleToDates(String styleName, Date date, Date... moreDates)
Add a style name to the given dates.
void addStyleToDates(String styleName, Date date)
Add a style name to the given dates.
final void addTransientStyleToDates(String styleName, Date date, Date... moreDates)
Adds the given style name to the specified dates, which must be visible.
void addTransientStyleToDates(String styleName, Date date)
Adds the given style name to the specified dates, which must be visible.
final void addTransientStyleToDates(String styleName, Iterable<Date> dates)
Adds the given style name to the specified dates, which must be visible.
HandlerRegistration addValueChangeHandler(ValueChangeHandler<Date> handler)
LeafValueEditor<Date> asEditor()
Returns a TakesValueEditor backed by the DatePicker.
Date getCurrentMonth()
Gets the current month the date picker is showing.
final Date getFirstDate()
Returns the first shown date.
final Date getHighlightedDate()
Gets the highlighted date (the one the mouse is hovering over), if any.
final Date getLastDate()
Returns the last shown date.
String getStyleOfDate(Date date)
Gets the style associated with a date (does not include styles set via addTransientStyleToDates(String, Iterable)).
final Date getValue()
Returns the selected date, or null if none is selected.
boolean isDateEnabled(Date date)
Is the visible date enabled?
boolean isDateVisible(Date date)
Is the date currently shown in the date picker?
void onLoad()
This method is called immediately after a widget becomes attached to the browser's document.
void removeStyleFromDates(String styleName, Date date, Date... moreDates)
Removes the styleName from the given dates (even if it is transient).
void removeStyleFromDates(String styleName, Date date)
Removes the styleName from the given dates (even if it is transient).
void removeStyleFromDates(String styleName, Iterable<Date> dates)
Removes the styleName from the given dates (even if it is transient).
void setCurrentMonth(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.
void setStyleName(String styleName)
Sets the date picker style name.
final void setTransientEnabledOnDates(boolean enabled, Iterable<Date> dates)
Sets a group of visible dates to be enabled or disabled.
final void setTransientEnabledOnDates(boolean enabled, Date date, Date... moreDates)
Sets a visible date to be enabled or disabled.
final void setTransientEnabledOnDates(boolean enabled, Date date)
Sets a visible date to be enabled or disabled.
final void setValue(Date newValue)
Sets the DatePicker's value.
final void setValue(Date newValue, boolean fireEvents)
Sets the DatePicker's value.
Protected Methods
final CalendarModel getModel()
Gets the CalendarModel associated with this date picker.
final MonthSelector getMonthSelector()
Gets the MonthSelector associated with this date picker.
final CalendarView getView()
Gets the CalendarView associated with this date picker.
final void refreshAll()
Refreshes all components of this date picker.
void setup()
Sets up the date picker.
[Expand]
Inherited Methods
From class com.google.gwt.user.client.ui.Composite
From class com.google.gwt.user.client.ui.Widget
From class com.google.gwt.user.client.ui.UIObject
From class java.lang.Object
From interface com.google.gwt.editor.client.IsEditor
From interface com.google.gwt.event.logical.shared.HasAttachHandlers
From interface com.google.gwt.event.logical.shared.HasHighlightHandlers
From interface com.google.gwt.event.logical.shared.HasShowRangeHandlers
From interface com.google.gwt.event.logical.shared.HasValueChangeHandlers
From interface com.google.gwt.event.shared.HasHandlers
From interface com.google.gwt.user.client.EventListener
From interface com.google.gwt.user.client.TakesValue
From interface com.google.gwt.user.client.ui.HasValue
From interface com.google.gwt.user.client.ui.IsWidget

Public Constructors

public DatePicker ()

Create a new date picker.

Protected Constructors

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

Creates a new date picker.

Parameters
monthSelector the month selector
view the view
model the model

Public Methods

public HandlerRegistration addHighlightHandler (HighlightHandler<Date> handler)

public HandlerRegistration addShowRangeHandler (ShowRangeHandler<Date> handler)

public HandlerRegistration addShowRangeHandlerAndFire (ShowRangeHandler<Date> handler)

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

Parameters
handler the handler
Returns
  • the handler registration

public void addStyleToDates (String styleName, Iterable<Date> dates)

Add a style name to the given dates.

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

Add a style name to the given dates.

public void addStyleToDates (String styleName, Date date)

Add a style name to the given dates.

public final void addTransientStyleToDates (String styleName, Date date, 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.

public void addTransientStyleToDates (String styleName, 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.

public final void addTransientStyleToDates (String styleName, Iterable<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.

public HandlerRegistration addValueChangeHandler (ValueChangeHandler<Date> handler)

public LeafValueEditor<Date> asEditor ()

Returns a TakesValueEditor backed by the DatePicker.

Returns

public 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

public final Date getFirstDate ()

Returns the first shown date.

Returns
  • the first date.

public final Date getHighlightedDate ()

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

Returns
  • the highlighted date

public final Date getLastDate ()

Returns the last shown date.

Returns
  • the last date.

public String getStyleOfDate (Date date)

Gets the style associated with a date (does not include styles set via addTransientStyleToDates(String, Iterable)).

Parameters
date the date
Returns
  • the styles associated with this date

public final Date getValue ()

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

Returns
  • the selected date, or null

public boolean isDateEnabled (Date date)

Is the visible date enabled?

Parameters
date the date, which must be visible
Returns
  • is the date enabled?

public boolean isDateVisible (Date date)

Is the date currently shown in the date picker?

Returns
  • is the date currently shown

public void onLoad ()

This method is called immediately after a widget becomes attached to the browser's document.

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

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

public void removeStyleFromDates (String styleName, Date date)

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

public void removeStyleFromDates (String styleName, Iterable<Date> dates)

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

public void setCurrentMonth (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

public void setStyleName (String styleName)

Sets the date picker style name.

Parameters
styleName the new style name

public final void setTransientEnabledOnDates (boolean enabled, Iterable<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.

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

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

public final void setTransientEnabledOnDates (boolean enabled, Date date)

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

public final void setValue (Date newValue)

Sets the DatePicker's value.

Parameters
newValue the new value

public final void setValue (Date newValue, boolean fireEvents)

Sets the DatePicker's value.

Parameters
newValue the new value for this date picker
fireEvents should events be fired.

Protected Methods

protected final CalendarModel getModel ()

Gets the CalendarModel associated with this date picker.

Returns
  • the model

protected final MonthSelector getMonthSelector ()

Gets the MonthSelector associated with this date picker.

Returns
  • the month selector

protected final CalendarView getView ()

Gets the CalendarView associated with this date picker.

Returns
  • the view

protected final void refreshAll ()

Refreshes all components of this date picker.

protected void setup ()

Sets up the date picker.