我有改變細胞的圖標,下面的代碼的問題:JavaFX的更改單元格圖標
TableColumn typeCol = new TableColumn("Account Type");
typeCol.setCellFactory(new Callback<TableColumn<Account, String>, TableCell<Account, String>>() {
@Override
public TableCell<Account, String> call(TableColumn<Account, String> param) {
TableCell<Account,String> cell = new TableCell<Account, String>(){
@Override
public void updateItem(Account item, boolean empty){
if (item != null){
VBox vb = new VBox();
vb.setAlignment(Pos.CENTER);
ImageView imgVw = new ImageView(item.getTypeIcon());
imgVw.setFitHeight(10);
imgVw.setFitWidth(10);
vb.getChildren().addAll(imgVw);
setGraphic(vb);
}
}
};
return cell;
}
});
typeCol.setMinWidth(100);
typeCol.setCellValueFactory(
new PropertyValueFactory<Account, String>("type"));
這裏的問題是,由於某種原因,我得到的連接的「方法不覆蓋或執行錯誤一種形式超類型的方法「。任何idaes?
如何訪問我的對象在updateItem方法中的方法? – uksz
@uksz:看我的編輯。基本上,'cellValueFactory'選擇要使用的項目的一部分,'cellFactory'返回的單元格顯示該數據(在本例中爲圖像)。 – fabian