[英]Using JTable to display ResultSet
I'm learning about JDBC with GUI. 我正在学习带GUI的JDBC。 I can do that the GUI display the data in SQL one by one.
我可以做到GUI在SQL中一一显示数据。 Then i want to display the data in table just like the result when i execute in SQL.
然后我想在表中显示数据,就像我在SQL中执行时的结果一样。 I saw that many people use two Vector to add data to JTable.
我看到很多人使用两个Vector向JTable添加数据。 I wonder is there anything else apart from Vector that I can do to add data to JTable.I really want to add some images in my post but i can't so sorry if it's uncovinient for everyone.
我想知道除了Vector之外我还能做些什么来向JTable添加数据。我真的很想在帖子中添加一些图像,但是如果每个人都不方便,我不会后悔。 Thanks for reading.
谢谢阅读。
I wonder is there anything else apart from Vector that I can do to add data to JTable.
我想知道除了Vector之外,还有什么我可以做的向JTable添加数据的事情。
The DefaultTableModel
uses Vectors
because it makes the TableModel
dynamic. DefaultTableModel
使用Vectors
是因为它使TableModel
动态化。 That is you can easily add or remove rows/columns from the model. 也就是说,您可以轻松地在模型中添加或删除行/列。
If you don't want to use a Vector then you can create a custom TableModel
to store the data any way that you want. 如果您不想使用Vector,则可以创建自定义
TableModel
来以所需的任何方式存储数据。
Check out Row Table Model . 查看行表模型 。 It gives an example
举个例子
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.