1

I am using TableView in JavaFX but tableview does not show any data here is my code.

public static class person {

    private final SimpleIntegerProperty SR;
    private final SimpleStringProperty URL;private person(int sr1,String url1 ){
    this.SR=new SimpleIntegerProperty(sr1);
    this.URL=new SimpleStringProperty(url1);
    }
    public int getsr() {
        return SR.get();
    }
    public void setsr(int sr1) {
       this.SR.set(sr1);
    }

    public String geturl() {
        return URL.get();
    }
    public void seturl(String url2) {
        this.URL.set(url2);
    } 
}

public TableView<person> table; TableColumn firstNameCol = new TableColumn("First Name");
   TableColumn lastNameCol = new TableColumn("Last Name");


private  final ObservableList<person> data1 =
    FXCollections.observableArrayList(
        new person((int)1, "Smith"),
        new person((int)2, "Johnson"),
        new person((int)3, "Williams"),
        new person((int)4, "Jones"),
        new person((int)5, "Brown")
    );


public void btnScrapping(ActionEvent event) {

    table.setEditable(true);
    firstNameCol.setMinWidth(100);
    firstNameCol.setCellValueFactory(new PropertyValueFactory<person,Integer>("SR"));
    lastNameCol.setMinWidth(500);
    lastNameCol.setCellValueFactory(new PropertyValueFactory<person,String>("URL"));
    table.setItems(data1);
     table.getColumns().addAll(firstNameCol, lastNameCol);
}
DVarga
  • 21,311
  • 6
  • 55
  • 60
  • 1
    Possible duplicate of [Javafx PropertyValueFactory not populating Tableview](http://stackoverflow.com/questions/17035478/javafx-propertyvaluefactory-not-populating-tableview) – fabian Jul 10 '16 at 13:17

0 Answers0