TextFormatter.valueProperty().bindBidirectional does not really bind

XMLWordPrintable

    • Type: Bug
    • Resolution: Not an Issue
    • Priority: P4
    • 9
    • Affects Version/s: 8u45
    • Component/s: javafx
    • None
    • Environment:

      Win 7 Pro SP1, JDK 8u45, 64 Bit

    • x86_64
    • windows_7

      The following code lines will not result in a working bidirectional binding:

      ObjectProperty<Integer> modelProperty = new SimpleObjectProperty<>();
      TextFormatter<Integer> t = (TextFormatter<Integer>) myTextField.textFormatterProperty().get();
      ObjectProperty<Integer> guiProperty = t.valueProperty();
      guiProperty.bindBidirectional(modelProperty);

      While this compiles and runs, when typing into the text field, the modelProperty will not fire any lilsteners.

      Now comes the strange thing. I do not use bindBidirectional but simply add two listeners:

      guiProperty.set(modelProperty.get());
      guiProperty.addListener((property, oldValue, newValue) -> modelProperty.set(newValue));
      modelProperty.addListener((property, oldValue, newValue) -> guiProperty.set(newValue));

      This DOES work: When typing in the TextField, all listeners registered with modelProperty DO FIRE.

      This is kind of weird, as typically one would think that bindBidirectional would actually do just that exact three lines under the hood...

            Assignee:
            Vadim Pakhnushev
            Reporter:
            Markus Karg
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: