我发现“刷新”我的tableview的唯一方法是:
private void refreshTable() {
tableView.getItems().clear();
try {
Thread.sleep(Etapa.SLEEP);
tableView.getItems().addAll(getList());
} catch (InterruptedException e) {
Thread.interrupted();
}
}
但似乎“进度条”无法正常工作:
p.getTableColumn().setVisible(false);
p.getTableColumn().setVisible(true);
有更好的方法吗?
我试过这些例子:
答案 0 :(得分:0)
columSituacao.setCellValueFactory(new Callback<CellDataFeatures<Tabela, Tabela>, ObservableValue<Tabela>>() {
public ObservableValue<Tabela> call(CellDataFeatures<Tabela, Tabela> p) {
return new ReadOnlyObjectWrapper<Tabela>(p.getValue());
}
});
columSituacao.setCellFactory(new Callback<TableColumn<Tabela, Tabela>, TableCell<Tabela, Tabela>>() {
public TableCell<Tabela, Tabela> call(TableColumn<Tabela, Tabela> param) {
final ProgressBar progressBar = new ProgressBar();
final HBox box = new HBox();
box.setPrefHeight(Progress.PREF_HEIGHT);
final Text text = new Text();
BorderPane border = new BorderPane();
border.setTop(text);
border.setBottom(progressBar);
BorderPane.setAlignment(text, Pos.CENTER);
box.getChildren().add(border);
return new TableCell<Tabela, Tabela>() {
@Override
protected void updateItem(Tabela item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
setGraphic(null);
} else {
if (text != null) {
text.textProperty().bind(item.etapaProperty());
}
progressBar.progressProperty().bind(item.progressProperty());
progressBar.prefWidthProperty().bind(this.widthProperty());
setGraphic(box);
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
}
}
};
}
});
tableView.getItems().addAll(lista);
tableView.getSelectionModel().selectFirst();
}