使ArrayList成为JTable [英] Making ArrayList to JTable
问题描述
我有一个
ArrayList<Map<String, Object>>
对象,我需要在JTable中显示这个数组的内容。
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?
地图包含多个地图-rows从表和所有行都添加到数组列表中,现在我需要以表格的形式在Swing应用程序中显示它们并对它们执行排序和过滤。
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.
推荐答案
对于数据,将列表嵌入 TableModel 。 DefaultTableModel 是最好的。
For datas embed your list in a TableModel. A DefaultTableModel is best.
对于列,将列表嵌入 TableColumnModel 。最好的是 DefaultTableModel 。
For columns, embed your list in a TableColumnModel. Best is a DefaultTableModel.
然后使用jtable 使用它的构造函数。
Then use the jtable constructor to use that.
这篇关于使ArrayList成为JTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!