无法将数据加载到javafx表格中

哈菲兹·阿蒂夫(Hafiz Atif)

需要帮助...这是表视图的输出,我找不到它为什么不显示除columns以外的任何行的数据。我的意思是它仅显示数据库列这是代码

 @Override
 public void start(Stage stage) throws Exception {
     TableView<ObservableList<String>> tableview = new TableView();
     ObservableList<ObservableList<String>> data = FXCollections.observableArrayList();
     Connection c = DBConnect.connect(); 
     String sql = "SELECT * FROM INVENTORY.CUSTOMER";
     ResultSet rs = c.createStatement().executeQuery(sql);
     ResultSetMetaData metaData = rs.getMetaData();
     int count = metaData.getColumnCount();
     for (int i = 0; i < count; i++){
         System.out.println(metaData.getColumnLabel(i + 1));
         TableColumn<ObservableList<String>, String> col = new TableColumn<>(metaData.getColumnLabel(i + 1));
         tableview.getColumns().add(col);

     }
     while(rs.next()) {
         ObservableList<String> row = FXCollections.observableArrayList();

         for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
             row.add(rs.getString(i));
         }
         data.add(row);
         System.out.println("Row [1] added " + row);
     }
     tableview.setItems(data);
     rs.close();

     Scene scene = new Scene(tableview);        
     stage.setScene(scene);
     stage.show();
 }

希望你们能找到错误的部分。我也没有任何错误。

法比安

您需要指定一个cellValueFactory否则,TableView不知道要在特定列中显示项目的哪一部分:

TableColumn<ObservableList<String>, String> col = new TableColumn<>(metaData.getColumnLabel(i + 1));
final int index = i; // is this the index corresponding to the list element to display???
col.setCellValueFactory(cellData -> Bindings.stringValueAt(cellData.getValue(), index));

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

无法将数据加载到javafx表格中

来自分类Dev

将数据加载到表格配置单元中

来自分类Dev

无法将数据加载到配置单元表中

来自分类Dev

QDialog:无法从用户输入将数据加载到QTableWidget中

来自分类Dev

无法将数据加载到Pig中的Hortonworks沙箱

来自分类Dev

无法将ArrayList数据加载到Android中的微调器

来自分类Dev

ember JSONAPIAdapter无法将数据正确加载到存储中

来自分类Dev

无法将CSV数据加载到GrapheneDB实例中

来自分类Dev

无法以正确的格式将数据加载到 hive 表中

来自分类Dev

Wicket - 在页面呈现后将数据加载到表格中

来自分类Dev

无法将js加载到MongoDB中

来自分类Dev

无法将脚本加载到iframe中

来自分类Dev

将arrayList数据加载到JTable中

来自分类Dev

将数据帧加载到列表中

来自分类Dev

将数据加载到ExpandableListView中

来自分类Dev

将数据从SQL加载到R中

来自分类Dev

将数据加载到UITableView中

来自分类Dev

从文件将数据加载到表中

来自分类Dev

将数据逐个加载到 UICollectionView 中

来自分类Dev

如何使用HTML将表格加载到多个网页中?

来自分类Dev

无法找到将数据库数据加载到的变量

来自分类Dev

尝试将本地页面加载到JavaFX WebEngine中

来自分类Dev

将组件加载到组件中时出现 JavaFX NullPointerException

来自分类Dev

PostgreSQL安装期间无法将sql模块加载到数据库集群中

来自分类Dev

无法将数据从Web服务加载到变量的ID类型中

来自分类Dev

无法使用pymysql将数据文件加载到MySQL中-找不到文件

来自分类Dev

无法将示例数据库从“凡人的SQL查询”加载到Oracle的SQL Developer中

来自分类Dev

无法将数据保存到文件,然后将其加载到Unity3d中

来自分类Dev

无法将 spark json 数据帧加载到配置单元表中

Related 相关文章

  1. 1

    无法将数据加载到javafx表格中

  2. 2

    将数据加载到表格配置单元中

  3. 3

    无法将数据加载到配置单元表中

  4. 4

    QDialog:无法从用户输入将数据加载到QTableWidget中

  5. 5

    无法将数据加载到Pig中的Hortonworks沙箱

  6. 6

    无法将ArrayList数据加载到Android中的微调器

  7. 7

    ember JSONAPIAdapter无法将数据正确加载到存储中

  8. 8

    无法将CSV数据加载到GrapheneDB实例中

  9. 9

    无法以正确的格式将数据加载到 hive 表中

  10. 10

    Wicket - 在页面呈现后将数据加载到表格中

  11. 11

    无法将js加载到MongoDB中

  12. 12

    无法将脚本加载到iframe中

  13. 13

    将arrayList数据加载到JTable中

  14. 14

    将数据帧加载到列表中

  15. 15

    将数据加载到ExpandableListView中

  16. 16

    将数据从SQL加载到R中

  17. 17

    将数据加载到UITableView中

  18. 18

    从文件将数据加载到表中

  19. 19

    将数据逐个加载到 UICollectionView 中

  20. 20

    如何使用HTML将表格加载到多个网页中?

  21. 21

    无法找到将数据库数据加载到的变量

  22. 22

    尝试将本地页面加载到JavaFX WebEngine中

  23. 23

    将组件加载到组件中时出现 JavaFX NullPointerException

  24. 24

    PostgreSQL安装期间无法将sql模块加载到数据库集群中

  25. 25

    无法将数据从Web服务加载到变量的ID类型中

  26. 26

    无法使用pymysql将数据文件加载到MySQL中-找不到文件

  27. 27

    无法将示例数据库从“凡人的SQL查询”加载到Oracle的SQL Developer中

  28. 28

    无法将数据保存到文件,然后将其加载到Unity3d中

  29. 29

    无法将 spark json 数据帧加载到配置单元表中

热门标签

归档