Reputation: 13859
I want to know how to disable the textfield of a JavaFx DatePicker? I was looking for this question and could not find it, so I am posting it.
Upvotes: 6
Views: 5381
Reputation: 69
If you want to disable the textfield and not have it greyed out you can do this:
DatePicker datePicker = new datePicker();
datePicker.getEditor().setDisable(true);
datePicker.getEditor().setOpacity(1);
Upvotes: 2
Reputation: 499
If you still want the textfield to look normal (not grayed out) but still not editable, you can set the editor not editable:
datePicker.getEditor().setEditable(false);
Upvotes: 6
Reputation: 13859
If you want to disable the DatePicker's textfield you should get the editor and setDisable to true.
DatePicker datePicker = new DatePicker(LocalDate.now());
datePicker.getEditor().setDisable(true);
Upvotes: 3