I want it to be like this. Inside the panel some details from database. Maybe a loop to do this?
我希望它是这样的。在面板内部的一些细节来自数据库。也许循环来做到这一点?
2 个解决方案
#1
You would generally display data from database tables in a JTable
. You need to do an SQL query to get the data from the database and then you copy the data from the ResultSet
to a TableModel
.
您通常会在JTable中显示数据库表中的数据。您需要执行SQL查询以从数据库获取数据,然后将数据从ResultSet复制到TableModel。
Take a look at the TableFromDatabase.java
class found in Table From Database for a generic example of this might be done.
请查看Table From Database中的TableFromDatabase.java类,以获取可能的一般示例。
#2
If you are using Netbeans 7.x and above, then Right Click on the desired package (or better create one) -> New -> Other -> Swing GUI forms -> MAster Detail Sample Form.
如果您使用的是Netbeans 7.x及更高版本,则右键单击所需的包(或更好地创建一个) - >新建 - >其他 - > Swing GUI表单 - > MAster Detail Sample Form。
Proceed forward, establish a database connection through the wizard, choose which entities you wish to display and let Netbeans do the rest for you.
继续,通过向导建立数据库连接,选择要显示的实体,让Netbeans为您完成剩下的工作。
#1
You would generally display data from database tables in a JTable
. You need to do an SQL query to get the data from the database and then you copy the data from the ResultSet
to a TableModel
.
您通常会在JTable中显示数据库表中的数据。您需要执行SQL查询以从数据库获取数据,然后将数据从ResultSet复制到TableModel。
Take a look at the TableFromDatabase.java
class found in Table From Database for a generic example of this might be done.
请查看Table From Database中的TableFromDatabase.java类,以获取可能的一般示例。
#2
If you are using Netbeans 7.x and above, then Right Click on the desired package (or better create one) -> New -> Other -> Swing GUI forms -> MAster Detail Sample Form.
如果您使用的是Netbeans 7.x及更高版本,则右键单击所需的包(或更好地创建一个) - >新建 - >其他 - > Swing GUI表单 - > MAster Detail Sample Form。
Proceed forward, establish a database connection through the wizard, choose which entities you wish to display and let Netbeans do the rest for you.
继续,通过向导建立数据库连接,选择要显示的实体,让Netbeans为您完成剩下的工作。