直到最近我才决定搬到javafx,这是我第一次尝试使用它的一部分。 我不明白为什么没有填充tableview。
System.out.println(" results ? " + row[col]);
输出正确的内容。
TableColumn<Table1, Integer> itemIdCol = new TableColumn<>("Id");
itemIdCol.setMinWidth(100);
TableColumn<Table1, String> NomeCol = new TableColumn<>("Nome");
NomeCol.setMinWidth(100);
Configuration configuration = new Configuration().configure();
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
SessionFactory factory = configuration.buildSessionFactory(builder.build());
Session session = factory.openSession();
session.beginTransaction();
String sQuery = "select * from Table1";
Query hQuery = session.createSQLQuery(sQuery);
List result = hQuery.list();
Iterator iterator = result.iterator();
itemIdCol.setCellValueFactory(new PropertyValueFactory<Table1, Integer>("itemId"));
NomeCol.setCellValueFactory(new PropertyValueFactory<Table1, String>("itemNome"));
while (iterator.hasNext()) {
Object[] row = (Object[])iterator.next();
for (int col = 0; col < row.length; col++) {
System.out.println("lista i risultati ??" + row[col]);
}
}
table1.getItems().setAll(FXCollections.observableList(hQuery.list()));
table1.getColumns().addAll(itemIdCol, NomeCol);
session.getTransaction().commit();
session.close();
TabPane tabPane = new TabPane();
BorderPane mainPane = new BorderPane();
Tab tabA = new Tab();
tabA.setText("Tab A");
tabA.setContent(table1);
tabPane.getTabs().add(tabA);
由于 ALB