1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| // 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() {
public void onValueChange(ValueChangeEvent 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
mypanel.add(text);
mypanel.add(datePicker); |
Partager