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

DatePicker listener might not be added when using second constructor

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8, openjfx11, openjfx17
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      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 ###

        Attachments

          Activity

            People

            Assignee:
            mhanl Marius Hanl
            Reporter:
            mhanl Marius Hanl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: