Skip to content

Commit

Permalink
Merge pull request #111 from dlsc-software-consulting-gmbh/fix-Calend…
Browse files Browse the repository at this point in the history
…arPicker-LocalData-Null

 Resolve CalendarPicker Crash When No Initial Value Set
  • Loading branch information
dlemmermann authored Feb 22, 2024
2 parents 4840345 + f333d48 commit f0d817a
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import org.kordamp.ikonli.javafx.FontIcon;

import java.time.LocalDate;
import java.time.YearMonth;
Expand Down Expand Up @@ -49,8 +48,11 @@ protected Node getPopupContent() {
if (view == null) {
CalendarPicker picker = getSkinnable();
view = picker.getCalendarView();
view.setYearMonth(YearMonth.from(picker.getValue()));
view.getSelectionModel().select(picker.getValue());
LocalDate pickerValue = picker.getValue();
if (pickerValue != null) {
view.setYearMonth(YearMonth.from(pickerValue));
view.getSelectionModel().select(pickerValue);
}
view.setFocusTraversable(false); // keep the picker focused / blue border
view.selectionModelProperty().addListener((obs, oldModel, newModel) -> bindSelectionModel(oldModel, newModel));
bindSelectionModel(null, view.getSelectionModel());
Expand Down

0 comments on commit f0d817a

Please sign in to comment.