Making ArrayList to JTable

后端 未结 2 1027
伪装坚强ぢ
伪装坚强ぢ 2021-01-06 08:15

I have an

ArrayList>

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

The Map - Ke

相关标签:
2条回答
  • 2021-01-06 08:58

    ArrayList<Map<String, Object>>

    This sounds like the wrong model for the job, there is not really a sensible way of turning this into a single table. Perhaps you mean

    Map<String, List<Object>>
    

    This would make a lot more sense. Now one single key (the column name) is mapped to multiple values (the column values).

    0 讨论(0)
  • 2021-01-06 08:59

    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.

    0 讨论(0)
提交回复
热议问题