如何在Javafx中创建具有特定行数和自动生成列数的TableView?

如何在Javafx中创建具有特定行数和自动生成列数的TableView?,java,javafx,tableview,javafx-8,Java,Javafx,Tableview,Javafx 8,我被这个问题困住了 我需要用有限的行包装一个表,该行根据列表的元素展开列 我考虑创建有限的对象子列表,然后将它们一个接一个地放到表上。然而,不幸的是,它不起作用,我不知道该怎么办 for(int i=0;i<opera.getLista().size()-f;) { //cycle the list RandomString session = new RandomString(); //give a random name to the column

我被这个问题困住了

我需要用有限的行包装一个表,该行根据列表的元素展开列

我考虑创建有限的对象子列表,然后将它们一个接一个地放到表上。然而,不幸的是,它不起作用,我不知道该怎么办

    for(int i=0;i<opera.getLista().size()-f;) { //cycle the list
        RandomString session = new RandomString(); //give a random name to the column
        TableColumn<ContenutoOpera,ImageView> column = new TableColumn<>(session.nextString()); //create a column
        column.setCellValueFactory(new PropertyValueFactory<>("Image"));//set the column
          tabella2.getColumns().add(column);//add the column
          Cont=Cont+1;//it dosn't do enything
          if(opera.getLista().size()==10) {//if the list size =10 get the sub-list, set the table and set the list counter to the max
              tabella2.getItems().setAll(opera.getLista(f));
          f=opera.getList().size();
          }else 
              if(opera.getLista().size()>10) {//if the list size > 10 get the sub-list, set the table and add 10 the the list counter
                  tabella2.getItems().setAll(opera.getLista(f));
                  f=f+10;
              }
              else
                  if(opera.getLista().size()<10) {//if the list size<10 get the sub-list size()-f+1 are the cycle that the for will do to add items to the list , set the table and set the list counter to the max
                      tabella2.getItems().setAll(opera.getLista1(opera.getLista().size()-f+1,f));
            f=opera.getLista().size();    
}

    }

for(int i=0;i您是否尝试提出您的解决方案?可能是一些示例代码?请阅读并相应执行。我已添加了代码