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

Bidirectional Binding does not maintain the invariant if one of the properties is bound

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • None
    • 8
    • javafx

      Following code snippet should write 0.0 to the output:

              DoubleProperty p0 = new SimpleDoubleProperty(0.0);
              DoubleProperty p05 = new SimpleDoubleProperty(0.5);
              
              DoubleProperty p1 = new SimpleDoubleProperty(1.0);
              DoubleProperty p2 = new SimpleDoubleProperty(2.0);
              
              p1.bindBidirectional(p2);
              
              p1.bind(p0);
              try {
              p2.set(0.5);
              } catch (Exception e) {
                  e.printStackTrace();
              }
              
              System.out.println(p2.get());

      The problem is that setting or binding a bidirectionally bound property (+ the counterpart property is unidirectionally bound) results in an Exception. The old value will not be restored however.

            msladecek Martin Sládeček
            msladecek Martin Sládeček
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: