This discussion is archived
3 Replies Latest reply: Dec 7, 2011 12:39 PM by KnutArneVedaa RSS

IntegerProperty implements ObservableValue<Number>

KnutArneVedaa Newbie
Currently Being Moderated
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


  • Correct Answers - 10 points
  • Helpful Answers - 5 points