title: cannot convert from StringProperty to ObservableValue<SimpleStringProperty> java/javafx
body: <p>I got the following error message in Java: "Cannot convert from <code>StringProperty</code> to <code>ObservableValue&lt;SimpleStringProperty&gt;</code>"</p>
  
  <p>I am using a TableView and I want to add data in a TableColumn. I have three charts who all should contain one attribute of the class product (name, quantity, price). </p>
  
  <p>I got the error in this line:</p>
  
  <pre><code>sname.setCellValueFactory(cellData -&gt; cellData.getValue().
  </code></pre>
  
  <p>Relevant Code:</p>
  
  <pre><code>import javafx.beans.property.SimpleDoubleProperty;
  import javafx.beans.property.SimpleIntegerProperty;
  import javafx.beans.property.SimpleStringProperty;
  import javafx.beans.value.ObservableValue;
  import javafx.event.ActionEvent;
  import javafx.event.EventHandler;
  import javafx.scene.control.Button;
  import javafx.scene.control.Label;
  import javafx.scene.control.ListView;
  import javafx.scene.control.TableView;
  import javafx.scene.control.TextField;
  import javafx.scene.control.cell.PropertyValueFactory;
  import javafx.scene.control.cell.TextFieldTableCell;
  import javafx.scene.layout.BorderPane;
  import javafx.scene.layout.HBox;
  import javafx.scene.layout.VBox;
  import javafx.util.Callback;
  import javafx.scene.control.TableColumn;
  import javafx.scene.control.TableColumn.CellDataFeatures;
  import javafx.scene.control.TableColumn.CellEditEvent;
  
  public class ViewShop extends BorderPane {
  
      private Button add;
      private Button remove;
      private TextField name;
      private TextField price;
      private TextField count;
      private VBox vbox;
      private HBox hbox;
      private TableView tv;
      private TableColumn&lt;Product, SimpleDoubleProperty&gt; sprice;
      private TableColumn&lt;Product, SimpleStringProperty&gt; sname;
      private TableColumn &lt;Product, SimpleIntegerProperty&gt;scount;
      private Label namelabel;
      private Label pricelabel;
      private Label countlabel;
  
      private ListView&lt;fpt.com.Product&gt; list; 
  
      public ViewShop()
      {
  
          remove=new Button("Remove");
          add=new Button("Add");
          name=new TextField();
          price=new TextField();
          count=new TextField();
          tv=new TableView&lt;fpt.com.Product&gt;();
          sprice=new TableColumn&lt;&gt;("Preis");
          sname= new TableColumn&lt;&gt;("Name");
          scount=new TableColumn&lt;&gt;("Anzahl");
          namelabel=new Label("Name");
          pricelabel=new Label("Preis");
          countlabel=new Label("Anzahl");
          tv.getColumns().addAll(sname,sprice,scount);
          hbox=new HBox();
          vbox=new VBox();
          list = new ListView&lt;fpt.com.Product&gt;();
  //      
  //       sname.setCellValueFactory(new Callback&lt;CellDataFeatures&lt;Product, SimpleStringProperty&gt;, ObservableValue&lt;SimpleStringProperty&gt;&gt;() {
  //           public ObservableValue&lt;SimpleStringProperty&gt; call(CellDataFeatures&lt;Product, SimpleStringProperty&gt; p) {
  //               // p.getValue() returns the Person instance for a particular TableView row
  //               return  p.getValue().nameProperty();
  //               
  //                       }
  //        });
          sname.setCellValueFactory(cellData -&gt; cellData.getValue().nameProperty());
          hbox.getChildren().addAll(remove, add);
          vbox.getChildren().addAll(namelabel,name,pricelabel ,price, countlabel , count, hbox);
          this.setRight(vbox);
          this.setLeft(tv);
      }
      public void addEventHandleradd(EventHandler&lt;ActionEvent&gt; eventHandler) {
          this.add.addEventHandler(ActionEvent.ACTION, eventHandler);
      }
      public void addEventHandlerremove(EventHandler&lt;ActionEvent&gt; eventHandler) {
          this.remove.addEventHandler(ActionEvent.ACTION, eventHandler);
      }
      public String giveName()
      {
          return name.getText();
      }
      public String givePrice()
      {
          return price.getText();
      }
      public String giveCount()
      {
          return count.getText();
      }
      public ListView&lt;fpt.com.Product&gt; getList()
      {
          return list;
      }
  
  
  }
  
  import javafx.beans.property.StringProperty;
  import javafx.beans.value.ChangeListener;
  import javafx.beans.value.ObservableValue;
  import javafx.beans.property.IntegerProperty;
  import javafx.beans.property.SimpleDoubleProperty;
  import javafx.beans.property.SimpleIntegerProperty;
  import javafx.beans.property.SimpleStringProperty;
  import javafx.beans.InvalidationListener;
  import javafx.beans.property.DoubleProperty;
  
  public class Product implements fpt.com.Product {
  
      Long id;
      SimpleStringProperty name;
      SimpleIntegerProperty quantity;
      SimpleDoubleProperty price;
  
      public Product(String name, int quantity, double price)
      {
          this.name=new SimpleStringProperty(name);
          this.quantity=new SimpleIntegerProperty(quantity);
          this.price=new SimpleDoubleProperty(price);
      }
  
  
  
  
      @Override
      public long getId() {
          return id;
      }
  
      @Override
      public void setId(long id) {
          this.id=id;
  
      }
  
      @Override
      public double getPrice() {
          return this.price.get();
      }
  
      @Override
      public void setPrice(double price) {
          this.price.set(price);
      }
  
      @Override
      public int getQuantity() {
          return this.quantity.get();
      }
  
      @Override
      public void setQuantity(int quantity) {
          this.quantity.set(quantity);
      }
  
      @Override
      public String getName() {
          return this.name.get();
      }
  
      @Override
      public void setName(String name) {
          this.name.set(name);
      }
  
      @Override
      public StringProperty nameProperty() {
          return name;
      }
  
      @Override
      public DoubleProperty priceProperty() {
          return price;
      }
  
      @Override
      public IntegerProperty quantityProperty() {
          return quantity;
      }
  
  }
  </code></pre>