I would like to know how do I populate a TableView with data... All the examples I have seen creates a TableView with columns and everything and add it to the scene. All done in the java code itself.
What I want to know: if I design my "form" in JavaFx Scene builder. Defining all the tables and columns in there. How do I access it to populate it from java? Or if someone can point me to a proper tutorial on this please.
I have defined my form in JavaFx Scene Builder - only a TableView with 3 Columns
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="288.0" prefWidth="293.0" xmlns:fx="http://javafx.com/fxml">
<children>
<TableView fx:id="tableView" layoutX="35.0" layoutY="28.0" prefHeight="200.0" prefWidth="227.0">
<columns>
<TableColumn prefWidth="75.0" text="UserId" fx:id="UserId" />
<TableColumn prefWidth="75.0" text="UserName" fx:id="UserName" />
<TableColumn prefWidth="75.0" text="Active" fx:id="Active" />
</columns>
</TableView>
</children>
</AnchorPane>
I have my data in a ResultSet in my Java code.
ResultSet rs = c.createStatement().executeQuery(SQL);
I need to populate the TableView.
Thanks