这个 0 是怎么来的,list 中 还没去请求数据呢
加了渲染序号的方法后就这样了
序号生成的方法是这个
public <T> void setRowNumberColumn(TableColumn<T, Long> id) {
id.setCellFactory((col) ->
new TableCell<>() {
@Override
public void updateItem(Long item, boolean empty) {
super.updateItem(item, empty);
this.setText(empty ? "" : String.valueOf(this.getIndex() + 1));
this.setGraphic(null);
}
}
);
}
在界面初始化的时候 加载了这个两个表格序号的方法
@Override
public void initialize(URL location, ResourceBundle resources) {
printers.setItems(FXCollections.observableArrayList(PrintServiceLookup.lookupPrintServices(null, null)));
cwfService.setRowNumberColumn(id);
cwfService.setRowNumberColumn(index);
}
问题出现在哪里呢
/**
* Returns the string representation of the {@code int} argument.
* <p>
* The representation is exactly the one returned by the
* {@code Integer.toString} method of one argument.
*
* @param i an {@code int}.
* @return a string representation of the {@code int} argument.
* @see java.lang.Integer#toString(int, int)
*/
public static String valueOf(int i) {
return Integer.toString(i);
}
返回的是 Integer