且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将所有数据库值插入到列表列表中?

更新时间:2022-05-21 23:07:07

我的意思是将这些数据库的值检索到 Object[][] 位置

i mean retrieve those database's values into Object[][] place

不要尝试这样做.您不知道将拥有多少行数据,因此您不知道该数组有多大.

Don't attempt to do that. You have no idea how many rows of data you will have so you have no idea how big to make the array.

相反,您应该:

  1. 使用列名"和零行数据"创建 DefaultTableModel.阅读相应构造函数的 API.

  1. Create the DefaultTableModel with the "column names" and "zero rows of data". Read the API for the appropriate constructor.

当您想向表格中添加数据时,您可以使用DefaultTableModeladdRow(...) 方法.

When you want to add data to the table you can use the addRow(...) method of the DefaultTableModel.