lcars
lcars

Reputation: 109

JavaFX: TableView(fxml) filling with data

either i am looking at it for to long... or i did not really understand it.

In any case i am trying to fill a tableview that has been created using fxml (inc. Columns) with data.

My Code works for the first (Title) column but not for the rest.

(Yes "data" has all the info in it... checked with debug.)

So can any1 tell me what i am doing wrong??

Here (hopefully all relevant) code (copied together):

@FXML private TableColumn<sresult,String> cl_title;
@FXML private TableColumn<sresult, String> cl_url;
@FXML private TableColumn<sresult, String> cl_poster;
@FXML private TableColumn<sresult, String> cl_date;
@FXML private TableColumn<sresult, String> cl_forum;

    String[][] search_res=null;
    try {
        search_res= search(tf_search.getText());
    } catch (MalformedURLException | SolrServerException | ParseException ex) {
        Logger.getLogger(MainUiController.class.getName()).log(Level.SEVERE, null, ex);
    }

    final ObservableList<sresult> data= FXCollections.observableArrayList();
    for ( String[] s : search_res){
        data.add(new sresult(s[0], s[2],s[3],s[4],s[1]));
    }


    cl_title.setCellValueFactory(
            new PropertyValueFactory<sresult,String>("Title"));
    cl_poster.setCellValueFactory(
            new PropertyValueFactory<sresult,String>("poster"));
    cl_date.setCellValueFactory(
            new PropertyValueFactory<sresult,String>("date"));
    cl_forum.setCellValueFactory(
            new PropertyValueFactory<sresult,String>("forum"));
    cl_url.setCellValueFactory(
            new PropertyValueFactory<sresult,String>("link"));        
    tb_results.setItems(data);



public class sresult {
    private final SimpleStringProperty Title;
    private final SimpleStringProperty poster;
    private final SimpleStringProperty date;
    private final SimpleStringProperty forum;
    private final SimpleStringProperty link;

    public sresult(String T, String p, String d, String f, String l) {
        this.Title = new SimpleStringProperty(T);
        this.poster = new SimpleStringProperty(p);
        this.date = new SimpleStringProperty(d);
        this.forum = new SimpleStringProperty(f);
        this.link = new SimpleStringProperty(l);
    }

    public String getTitle() {
        return Title.get();
    }
    public void setTitle(String T) {
        Title.set(T);
    }

    public String getposter() {
        return poster.get();
    }
    public void setposter(String p) {
        poster.set(p);
    }

    public String getdate() {
        return date.get();
    }
    public void setdate(String d) {
        date.set(d);
    }
    public String getforum() {
        return forum.get();
    }
    public void setforum(String f) {
        forum.set(f);
    }

    public String getlink() {
        return link.get();
    }
    public void setlink(String l) {
        link.set(l);
    }
}

Thank you!

Upvotes: 0

Views: 2452

Answers (1)

lcars
lcars

Reputation: 109

Ok,

This was simular enough for me to get the answer.

The getter and setters need to have a Capital letter after get/set.

e.g. public String getTitle() vs public String gettitle()

not really sure why java is forcing this...

Anyway thanks to jewelsea for his answer on the other question.

Upvotes: 3

Related Questions