4

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.

0

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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).

1 Comment

hmm, makes sense, let me check it this way too!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.