modules/controls/src/main/java/com/sun/javafx/scene/control/DatePickerContent.java

Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization

@@ -21,11 +21,11 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
-package com.sun.javafx.scene.control.skin;
+package com.sun.javafx.scene.control;
 
 import java.time.DateTimeException;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DecimalStyle;

@@ -40,10 +40,11 @@
 import java.util.Locale;
 
 import static java.time.temporal.ChronoField.*;
 import static java.time.temporal.ChronoUnit.*;
 
+import com.sun.javafx.scene.control.skin.*;
 import javafx.application.Platform;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleObjectProperty;
 import javafx.beans.value.WeakChangeListener;
 import javafx.event.EventHandler;

@@ -113,11 +114,11 @@
 
     static String getString(String key) {
         return ControlResources.getString("DatePicker."+key);
     }
 
-    DatePickerContent(final DatePicker datePicker) {
+    public DatePickerContent(final DatePicker datePicker) {
         this.datePicker = datePicker;
 
         getStyleClass().add("date-picker-popup");
 
         daysPerWeek = getDaysPerWeek();

@@ -184,11 +185,13 @@
         gridPane.sceneProperty().addListener(new WeakChangeListener<Scene>((ov, oldScene, newScene) -> {
             if (oldScene != null) {
                 oldScene.focusOwnerProperty().removeListener(weakFocusOwnerListener);
             }
             if (newScene != null) {
+                Platform.runLater(() -> {
                 newScene.focusOwnerProperty().addListener(weakFocusOwnerListener);
+                });
             }
         }));
         if (gridPane.getScene() != null) {
             gridPane.getScene().focusOwnerProperty().addListener(weakFocusOwnerListener);
         }

@@ -287,11 +290,11 @@
     }
 
     private ObjectProperty<YearMonth> displayedYearMonth =
         new SimpleObjectProperty<YearMonth>(this, "displayedYearMonth");
 
-    ObjectProperty<YearMonth> displayedYearMonthProperty() {
+    public ObjectProperty<YearMonth> displayedYearMonthProperty() {
         return displayedYearMonth;
     }
 
 
     protected BorderPane createMonthYearPane() {

@@ -366,11 +369,11 @@
         forwardYearButton.setOnAction(t -> {
             forward(1, YEARS, false);
         });
 
         yearSpinner.getChildren().addAll(backYearButton, yearLabel, forwardYearButton);
-yearSpinner.setFillHeight(false);
+        yearSpinner.setFillHeight(false);
         monthYearPane.setRight(yearSpinner);
 
         return monthYearPane;
     }
 

@@ -378,19 +381,19 @@
         updateMonthLabelWidth();
         updateDayNameCells();
         updateValues();
     }
 
-    void updateValues() {
+    public void updateValues() {
         // Note: Preserve this order, as DatePickerHijrahContent needs
         // updateDayCells before updateMonthYearPane().
         updateWeeknumberDateCells();
         updateDayCells();
         updateMonthYearPane();
     }
 
-    void updateGrid() {
+    public void updateGrid() {
         gridPane.getColumnConstraints().clear();
         gridPane.getChildren().clear();
 
         int nCols = daysPerWeek + (datePicker.isShowWeekNumbers() ? 1 : 0);
 

@@ -417,11 +420,11 @@
                 gridPane.add(dayCells.get(row*daysPerWeek+col), col + nCols - daysPerWeek, row + 2);
             }
         }
     }
 
-    void updateDayNameCells() {
+    public void updateDayNameCells() {
         // first day of week, 1 = monday, 7 = sunday
         int firstDayOfWeek = WeekFields.of(getLocale()).getFirstDayOfWeek().getValue();
 
         // july 13th 2009 is a Monday, so a firstDayOfWeek=1 must come out of the 13th
         LocalDate date = LocalDate.of(2009, 7, 12 + firstDayOfWeek);

@@ -429,11 +432,11 @@
             String name = weekDayNameFormatter.withLocale(getLocale()).format(date.plus(i, DAYS));
             dayNameCells.get(i).setText(titleCaseWord(name));
         }
     }
 
-    void updateWeeknumberDateCells() {
+    public void updateWeeknumberDateCells() {
         if (datePicker.isShowWeekNumbers()) {
             final Locale locale = getLocale();
             final int maxWeeksPerMonth = 6; // TODO: Get this from chronology?
 
             LocalDate firstOfMonth = displayedYearMonth.get().atDay(1);

@@ -448,11 +451,11 @@
                 weekNumberCells.get(i).setText(cellText);
             }
         }
     }
 
-    void updateDayCells() {
+    public void updateDayCells() {
         Locale locale = getLocale();
         Chronology chrono = getPrimaryChronology();
         int firstOfMonthIdx = determineFirstOfMonthDayOfWeek();
         YearMonth curMonth = displayedYearMonth.get();
 

@@ -697,11 +700,11 @@
             }
         }
         return dayCells.get(dayCells.size()/2+1);
     }
 
-    void clearFocus() {
+    public void clearFocus() {
         LocalDate focusDate = datePicker.getValue();
         if (focusDate == null) {
             focusDate = LocalDate.now();
         }
         if (YearMonth.from(focusDate).equals(displayedYearMonth.get())) {