0
I’m trying to load a table view with the result of a query. The result of the query is sent to an Observablelist which is then called in the controller.
I do not get any error but it also does not show any result. Can anyone help me find the right path? Code on the controller
public class HomeController implements Initializable {
@FXML
private TableView prova;
@FXML
private TableColumn colId;
@FXML
private TableColumn colTipo;
@FXML
private TableColumn colProva;
@FXML
private TableColumn colData;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
ObservableList<Prova> list = FXCollections.observableArrayList(
new Prova(1, "aaa", "aaa", "bbb"),
new Prova(2, "bb", "bb", "bbb"),
new Prova(3, "cc", "cc", "cc")
);
prova.getItems().setAll(list);
// prova.getItems().addAll(list); Tambem não Trabalha
try {
OprationsOnDB.loadTableProva().forEach((tab) -> {
//itemIdCol.setCellFactory(new PropertyValueFactory((String) tab));
System.out.println("Stuff with " + tab.toString());
});
} catch (SQLException ex) {
Logger.getLogger(HomeController.class.getName()).log(Level.SEVERE, null, ex);
}
}
FXML code
<TableView fx:id="prova" GridPane.columnIndex="0" GridPane.rowIndex="1">
<columns>
<TableColumn fx:id="colId" text="#" prefWidth="100"/>
<TableColumnfx:id="colLocal"text="Local" prefWidth="100"/>
<TableColumn fx:id="colProva" text="Prova" prefWidth="200"/>
<TableColumnfx:id="colData" text="Data" prefWidth="200"/>
</columns>
</TableView>
Somebody please help me!
– Helder Pereira