我陷入了这个问题。
我需要创建一个行数有限的表,该表会根据列表的元素扩展列。
我考虑过创建对象的有限子列表,然后将它们一个一个地放在桌子上。但是不幸的是,它不起作用,我也不知道该怎么办
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();
}
}
忽略任何语法错误,逻辑仍然无法正常工作