0
I have the following table:
When clicking a button, I want a function to run on each line read:
private void inserirResultadosUsuario() {
//Necessário pegar o valor de cada linha e de cada coluna por vez
}
Complete controller code:
@FXML private Button btnSalvar;
@FXML private TableView<Partida> tabela;
@FXML private TextField txtRodada;
@FXML private Button btnRodadas;
@FXML private TableColumn<Partida, String> clmTime1;
@FXML private TableColumn<Partida, Integer> clmPlacar1;
@FXML private TableColumn<String, String> clmX;
@FXML private TableColumn<Partida, Integer> clmPlacar2;
@FXML private TableColumn<Partida, String> clmTime2;
public void initialize(URL location, ResourceBundle resources) {
clmTime1.setCellValueFactory(new PropertyValueFactory<>("cod_time1"));
clmPlacar1.setCellValueFactory(new PropertyValueFactory<>("gol_time1"));
clmX.setCellValueFactory(new PropertyValueFactory<>("X"));
clmPlacar2.setCellValueFactory(new PropertyValueFactory<>("gol_time2"));
clmTime2.setCellValueFactory(new PropertyValueFactory<>("cod_time2"));
}
@FXML
private void refreshTable() {
ArrayList<Partida> listaPartida = new partidaDAO().listarPartidas();
ObservableList<Partida> observableList = FXCollections.observableArrayList(listaPartida);
tabela.setItems(observableList);
}
@FXML
private void mostrarTabelaDeAcordoComRodada() {
int i = Integer.parseInt(txtRodada.getText());
ArrayList<Partida> listarPartidaEspecifica = partidaDAO.listarPartidasEspecifica(i);
ObservableList<Partida> observableList = FXCollections.observableArrayList(listarPartidaEspecifica);
tabela.setItems(observableList);
}
@FXML
private void inserirResultadosUsuario() {
}
How could I do that?
I took a look here and could not visualize how to make this change, I changed the original post with the full controller, can take a look?
– Gabriel Henrique
tries the following table.getItems(). foreach(item -> insertResults(); Says if there is an error
– Isaías de Lima Coelho