Reputation: 327
Is it possible to have a DatePicker
object in JavaFX disabled, looking like an enabled DatePicker
?
Or, how to disable the popup window for the selection of the date ?
I tried with:
myDp.setDisable(true);
myDp.setStyle("-fx-background-color: white");
but no other ideas.. any help?
Thanks !!!
Upvotes: 1
Views: 1105
Reputation: 327
Solved
I used in my code:
myDp.setDisable(true);
myDp.setStyle(" -fx-opacity: 1.0;");
myDp.getEditor().setStyle("-fx-opacity: 1.0;")
when I want that it looks like if it's disabled, while if I want that it looks like if it's disabled:
myDp.setStyle(" -fx-opacity: 0.4;");
myDp.getEditor().setStyle("-fx-opacity: 0.4;")
thanks to ItachiUchiha
Upvotes: 1
Reputation: 36722
A single solution can work for both.
Keep your DatePicker disabled and add the following css :
/* For date-picker */
.date-picker:disabled {
-fx-opacity: 1.0;
}
/* For date-picker textfield */
.date-picker > .date-picker-display-node:disabled {
-fx-opacity: 1.0;
}
Upvotes: 0