public class DateBox extends Composite implements HasEnabled, HasValue<java.util.Date>, IsEditor<LeafValueEditor<java.util.Date>>
DatePicker when the user focuses on it.
DateBox.DefaultFormat when the text does not represent a date that
can be parsed
public class DateBoxExample implements EntryPoint {
public void onModuleLoad() {
DateBox dateBox = new DateBox();
dateBox.setValue(new Date());
RootPanel.get().add(dateBox);
}
}
| Modifier and Type | Class and Description |
|---|---|
static class |
DateBox.DefaultFormat
Default
DateBox.Format class. |
static interface |
DateBox.Format
Implemented by a delegate to handle the parsing and formating of date
values.
|
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_STYLENAME
Default style name.
|
DEBUG_ID_PREFIX| Constructor and Description |
|---|
DateBox()
Create a date box with a new
DatePicker. |
DateBox(DatePicker picker,
java.util.Date date,
DateBox.Format format)
Create a new date box.
|
| Modifier and Type | Method and Description |
|---|---|
HandlerRegistration |
addValueChangeHandler(ValueChangeHandler<java.util.Date> handler)
Adds a
ValueChangeEvent handler. |
LeafValueEditor<java.util.Date> |
asEditor()
Returns a
TakesValueEditor backed by the DateBox. |
int |
getCursorPos()
Gets the current cursor position in the date box.
|
DatePicker |
getDatePicker()
Gets the date picker.
|
boolean |
getFireNullValues()
Returns true iff the date box will fire
ValueChangeEvents with a
date value of null for invalid or empty string values. |
DateBox.Format |
getFormat()
Gets the format instance used to control formatting and parsing of this
DateBox. |
int |
getTabIndex()
Gets the date box's position in the tab index.
|
TextBox |
getTextBox()
Get text box.
|
java.util.Date |
getValue()
Get the date displayed, or null if the text box is empty, or cannot be
interpreted.
|
void |
hideDatePicker()
Hide the date picker.
|
boolean |
isDatePickerShowing()
Returns true if date picker is currently showing, false if not.
|
boolean |
isEnabled()
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 fire
ValueChangeEvents with a
date value of null 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 this
DateBox. |
void |
setTabIndex(int index)
Sets the date box's position in the tab index.
|
void |
setValue(java.util.Date date)
Set the date.
|
void |
setValue(java.util.Date date,
boolean fireEvents)
Sets this object's value.
|
void |
showDatePicker()
Parses the current date box's value and shows that date.
|
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidgetaddAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEventsaddStyleDependentName, 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, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitfireEventpublic static final java.lang.String DEFAULT_STYLENAME
public DateBox()
DatePicker.public DateBox(DatePicker picker, java.util.Date date, DateBox.Format format)
date - the default date.picker - the picker to drop down from the date boxformat - to use to parse and format datespublic HandlerRegistration addValueChangeHandler(ValueChangeHandler<java.util.Date> handler)
HasValueChangeHandlersValueChangeEvent handler.addValueChangeHandler in interface HasValueChangeHandlers<java.util.Date>handler - the handlerpublic LeafValueEditor<java.util.Date> asEditor()
TakesValueEditor backed by the DateBox.asEditor in interface IsEditor<LeafValueEditor<java.util.Date>>Editor of type Epublic int getCursorPos()
public DatePicker getDatePicker()
public boolean getFireNullValues()
ValueChangeEvents with a
date value of null for invalid or empty string values.public DateBox.Format getFormat()
DateBox.public int getTabIndex()
public TextBox getTextBox()
public java.util.Date getValue()
getValue in interface TakesValue<java.util.Date>getValue in interface HasValue<java.util.Date>TakesValue.setValue(V)public void hideDatePicker()
public boolean isDatePickerShowing()
public boolean isEnabled()
isEnabled in interface HasEnabledpublic void setAccessKey(char key)
key - the date box's access keypublic void setEnabled(boolean enabled)
setEnabled in interface HasEnabledenabled - is the box enabledpublic void setFireNullValues(boolean fireNullValues)
ValueChangeEvents with a
date value of null for invalid or empty string values.public void setFocus(boolean focused)
focused - whether this widget should take focus or release itpublic void setFormat(DateBox.Format format)
DateBox. If this DateBox is not empty, the contents of date
box will be replaced with current contents in the new format.format - the new date formatpublic void setTabIndex(int index)
-1 will cause this widget to
be removed from the tab order.index - the date box's tab indexpublic void setValue(java.util.Date date)
setValue in interface TakesValue<java.util.Date>setValue in interface HasValue<java.util.Date>date - the object's new valueTakesValue.getValue()public void setValue(java.util.Date date,
boolean fireEvents)
HasValueValueChangeEvent 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.
public void showDatePicker()