[英]Java: Retrieving data from Database and load in JTable
I know how to retrieve data (just text in a table) from a database in Java and how to show it in the console. 我知道如何从Java数据库中检索数据(只是表中的文本),以及如何在控制台中显示数据。 But I want to load it in a JTable.
但我想将其加载到JTable中。 Is there a good (modern) way (tutorial), without using Vectors?
有没有使用Vector的良好(现代)方法(教程)?
查看本教程: 如何使用表
Seems your question is similar with these two questions: 似乎您的问题与以下两个问题相似:
How to fill data in a JTable with database? 如何用数据库填充JTable中的数据?
Check out GlazedLists it comes with ready made TableModels that are based on modern collection interfaces. 查看GlazedLists,它带有基于现代集合接口的现成TableModel。
http://www.glazedlists.com/ http://www.glazedlists.com/
If you don't want to use an extra library. 如果您不想使用额外的库。 You can easily implement your own javax.swing.table.TableModel .
您可以轻松实现自己的javax.swing.table.TableModel 。 I like to implement TableModel and java.util.List so I'm working with just a simple List, and hooking up any List easily.
我喜欢实现TableModel和java.util.List,所以我只使用一个简单的List,并轻松连接任何List。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.