Class DateBox
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.DateBox
- All Implemented Interfaces:
IsEditor<LeafValueEditor<Date>>
,HasAttachHandlers
,HasValueChangeHandlers<Date>
,HasHandlers
,EventListener
,TakesValue<Date>
,HasEnabled
,HasValue<Date>
,HasVisibility
,IsRenderable
,IsWidget
public class DateBox
extends Composite
implements HasEnabled, HasValue<Date>, IsEditor<LeafValueEditor<Date>>
A text box that shows a
DatePicker
when the user focuses on it.
CSS Style Rules
- .gwt-DateBox
- default style name
- .dateBoxPopup
- Applied to the popup around the DatePicker
- .dateBoxFormatError
- Default style for when the date box has bad input. Applied by
DateBox.DefaultFormat
when the text does not represent a date that can be parsed
Example
public class DateBoxExample implements EntryPoint { public void onModuleLoad() { DateBox dateBox = new DateBox(); dateBox.setValue(new Date()); RootPanel.get().add(dateBox); } }
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
DefaultDateBox.Format
class.static interface
Implemented by a delegate to handle the parsing and formating of date values.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
ConstructorDescriptionDateBox()
Create a date box with a newDatePicker
.DateBox
(DatePicker picker, Date date, DateBox.Format format) Create a new date box. -
Method Summary
Modifier and TypeMethodDescriptionaddValueChangeHandler
(ValueChangeHandler<Date> handler) Adds aValueChangeEvent
handler.asEditor()
Returns aTakesValueEditor
backed by the DateBox.int
Gets the current cursor position in the date box.Gets the date picker.boolean
Returns true iff the date box will fireValueChangeEvents
with a date value ofnull
for invalid or empty string values.Gets the format instance used to control formatting and parsing of thisDateBox
.int
Gets the date box's position in the tab index.Get text box.getValue()
Get the date displayed, or null if the text box is empty, or cannot be interpreted.void
Hide the date picker.boolean
Returns true if date picker is currently showing, false if not.boolean
Returns true if the date box is enabled, false if not.void
setAccessKey
(char key) Sets the date box's 'access key'.void
setEnabled
(boolean enabled) Sets whether the date box is enabled.void
setFireNullValues
(boolean fireNullValues) Sets whether or not the date box will fireValueChangeEvents
with a date value ofnull
for invalid or empty string values.void
setFocus
(boolean focused) Explicitly focus/unfocus this widget.void
setFormat
(DateBox.Format format) Sets the format used to control formatting and parsing of dates in thisDateBox
.void
setTabIndex
(int index) Sets the date box's position in the tab index.void
Set the date.void
Sets this object's value.void
Parses the current date box's value and shows that date.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, onLoad, 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, 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
-
Field Details
-
DEFAULT_STYLENAME
Default style name.- See Also:
-
-
Constructor Details
-
DateBox
public DateBox()Create a date box with a newDatePicker
. -
DateBox
Create a new date box.- Parameters:
picker
- the picker to drop down from the date boxdate
- the default date.format
- to use to parse and format dates
-
-
Method Details
-
asEditor
Returns aTakesValueEditor
backed by the DateBox.- Specified by:
asEditor
in interfaceIsEditor<LeafValueEditor<Date>>
- Returns:
- an
Editor
of type E
-
getCursorPos
public int getCursorPos()Gets the current cursor position in the date box.- Returns:
- the cursor position
-
getDatePicker
Gets the date picker.- Returns:
- the date picker
-
getFireNullValues
public boolean getFireNullValues()Returns true iff the date box will fireValueChangeEvents
with a date value ofnull
for invalid or empty string values. -
getFormat
Gets the format instance used to control formatting and parsing of thisDateBox
.- Returns:
- the format
-
getTabIndex
public int getTabIndex()Gets the date box's position in the tab index.- Returns:
- the date box's tab index
-
getTextBox
Get text box.- Returns:
- the text box used to enter the formatted date
-
getValue
Get the date displayed, or null if the text box is empty, or cannot be interpreted. -
hideDatePicker
public void hideDatePicker()Hide the date picker. -
isDatePickerShowing
public boolean isDatePickerShowing()Returns true if date picker is currently showing, false if not. -
isEnabled
public boolean isEnabled()Returns true if the date box is enabled, false if not.- Specified by:
isEnabled
in interfaceHasEnabled
-
setAccessKey
public void setAccessKey(char key) Sets the date box's 'access key'. This key is used (in conjunction with a browser-specific modifier key) to automatically focus the widget.- Parameters:
key
- the date box's access key
-
setEnabled
public void setEnabled(boolean enabled) Sets whether the date box is enabled.- Specified by:
setEnabled
in interfaceHasEnabled
- Parameters:
enabled
- is the box enabled
-
setFireNullValues
public void setFireNullValues(boolean fireNullValues) Sets whether or not the date box will fireValueChangeEvents
with a date value ofnull
for invalid or empty string values. -
setFocus
public void setFocus(boolean focused) Explicitly focus/unfocus this widget. Only one widget can have focus at a time, and the widget that does will receive all keyboard events.- Parameters:
focused
- whether this widget should take focus or release it
-
setFormat
Sets the format used to control formatting and parsing of dates in thisDateBox
. If thisDateBox
is not empty, the contents of date box will be replaced with current contents in the new format.- Parameters:
format
- the new date format
-
setTabIndex
public void setTabIndex(int index) Sets the date box's position in the tab index. If more than one widget has the same tab index, each such widget will receive focus in an arbitrary order. Setting the tab index to-1
will cause this widget to be removed from the tab order.- Parameters:
index
- the date box's tab index
-
setValue
Set the date. -
setValue
Description copied from interface:HasValue
Sets this object's value. FiresValueChangeEvent
when fireEvents is true and the new value does not equal the existing value.It is acceptable to fail assertions or throw (documented) unchecked exceptions in response to bad values.
-
showDatePicker
public void showDatePicker()Parses the current date box's value and shows that date.