title: JavaFX Properties in TableView
body: <p>I am teaching myself how to work with JavaFX properties within the TableView and am having trouble with some property types. I have an object Person that contains two properties</p>
  
  <pre><code>public class Person {
  
      private final StringProperty firstName;
      private final IntegerProperty age;
  
      public Person(String firstName, Integer age) {
          this.firstName = new SimpleStringProperty(firstName);
          this.age = new SimpleIntegerProperty(age);
      }
  
  
      public Integer getAge() {
          return age.get();
      }
  
      public void setAge(Integer age) {
          this.age.set(age);
      }
  
      public IntegerProperty ageProperty() {
          return age;
      }
  
      public String getFirstName() {
          return firstName.get();
      }
  
      public void setFirstName(String firstName) {
          this.firstName.set(firstName);
      }
  
      public StringProperty firstNameProperty() {
          return firstName;
      }
  
  }
  </code></pre>
  
  <p>Once created by goal is to use this object in a TableView. I've created the two table columns like this.</p>
  
  <pre><code>TableColumn&lt;Person, String&gt; firstNameColumn = new TableColumn&lt;Person, String&gt;("First Name");
  TableColumn&lt;Person, Integer&gt; ageColumn = new TableColumn&lt;Person, Integer&gt;("Age");
  </code></pre>
  
  <p>I then want to set the cell value factory using Lambda expressions. This is where the problem arises. The StringProperty firstName works just fine. However, the IntegerProperty gives me the error message <strong>"Type mismatch: cannot convert from <code>IntegerProperty</code> to <code>ObservableValue&lt;Integer&gt;</code>"</strong></p>
  
  <pre><code>firstNameColumn.setCellValueFactory(cellData -&gt; cellData.getValue().firstNameProperty());
  ageColumn.setCellValueFactory(cellData -&gt; cellData.getValue().ageProperty());
  </code></pre>
  
  <p>Can anyone shed some light on what is going wrong with the ageColumn.setCellValueFactory(...)? Any help would be greatly appreciated.</p>
  
  <p>Thanks!</p>