Reputation: 5
How to set the datepicker to an empty field?
I have button the user will confirm with the button I want the datepicker to delete whatever the user chose. For example, for the textfield i used the following statement:
TextField userName = new TextField();
Then I clean it using the following statement:
userName.setText("");
but I can't do the same thing for the datepicker object since it has not setText function.
And the same thing for the ComboBox object. I dont want it to choose the first one. I want it to reshow the PromptText message. For example,
ComboBox items = new ComboBox();
items.setPromptText("Choose From Below");
Once the user choose from it, and press the button how to redisplay the prompt message again.
Upvotes: 0
Views: 2111
Reputation: 209724
ComboBoxBase
defines a valueProperty
that is inherited by both DatePicker
and ComboBox
and represents the currently selected item. So you can call
datePicker.setValue(null);
or
// items is the combo box you defined:
items.setValue(null);
to clear the value from either one.
Upvotes: 1