3 Replies Latest reply on Dec 7, 2011 8:39 PM by Knut Arne Vedaa

    IntegerProperty implements ObservableValue<Number>

    Knut Arne Vedaa
      I think I may have found my first wtf in the JavaFX API: :)
      class IntegerProperty implements ObservableValue<Number>
      instead of
      class IntegerProperty implements ObservableValue<Integer>
      Now, I assume this has not been decided at random and that there is some rationale behind. I'm curious about what that is.

      However, it results in the following trivial problem:
      class Person(StringProperty name, IntegerProperty age)
      ...then in some TableView<Person>:
                  ageCol.setCellValueFactory(new Callback<CellDataFeatures<Person, Integer>, ObservableValue<Integer>>() {
                      public ObservableValue<Integer> call(CellDataFeatures<Person, Integer> p) {
                          return p.getValue().age;  // THIS DOESN'T WORK! 
      You'll have to change the return line to:
      return new ReadOnlyObjectWrapper<Integer>(p.getValue().age.getValue());
      Am I supposed to use
      in my data model instead of IntegerProperty?

      Edited by: Knut Arne Vedaa on Dec 4, 2011 7:41 AM