Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8277756

DatePicker listener might not be added when using second constructor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • jfx19
    • jfx11, 8, jfx17
    • javafx
    • generic
    • generic

      The DatePicker has two constructors.
      One default constructor with no parameters and a second with 'LocalDate' as parameter.
      The default constructor uses 'this(null)' and adds two additional listener after.

      If the second constructor with 'LocalDate' is used those two listener won't be added.

      Fix would be the same as in other controls:
      The listener should be added at the second constructor where the first constructor is also referring to.

      ### SOURCE ###
         public DatePicker() {
              this(null);
              // Here the constructor will add two additional listeners
              valueProperty().addListener(observable -> {
                    [...]
              });
              chronologyProperty().addListener(observable -> {
                     [...]
                  }
              });
          }

          public DatePicker(LocalDate localDate) {
              setValue(localDate);
              getStyleClass().add(DEFAULT_STYLE_CLASS);
              setAccessibleRole(AccessibleRole.DATE_PICKER);
              setEditable(true);
          }
      ### SOURCE END ###

            mhanl Marius Hanl
            mhanl Marius Hanl
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: