将 ArrayList 转换为 JTable [英] Making ArrayList to JTable

查看:33
本文介绍了将 ArrayList 转换为 JTable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个

ArrayList>

对象,我需要在 JTable 中显示这个数组的内容.

Map - Key 是列名,Object 是数据,怎么放?

基本上地图包含来自表的多行,并且所有行都添加到数组列表中,现在我需要以表的形式在 Swing 应用程序中显示它们,并对它们执行排序和过滤.

解决方案

对于数据,将您的列表嵌入TableModel.DefaultTableModel 是最好的.>

对于列,将您的列表嵌入表列模型.最好的是 DefaultTableModel.>

然后使用jtable 使用它的构造函数.

I have an

ArrayList<Map<String, Object>>

Object, I need to display the content of this array in a JTable.

The Map - Key is the column name and Object is the data, how can I put it up?

Baiscally the Map contains multiple-rows from a table and all the rows are added to the array list, now I need to display them in a Swing application in the form of a table and perform sorting and filtering on them.

解决方案

For datas embed your list in a TableModel. A DefaultTableModel is best.

For columns, embed your list in a TableColumnModel. Best is a DefaultTableModel.

Then use the jtable constructor to use that.

这篇关于将 ArrayList 转换为 JTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆