JTable padding using one object per line

I am sure that this is possible, but it is difficult for me to find the appropriate documentation or a simple example for this situation.

For example, for the sake of, say, I have an object like this:

public class Person {
    private final String name;
    private final int age;
    private final String address;

    // Constructor, Getters and Setters
}

Now I would like to do something like this:

myTableModel.addColumn("name");
myTableModel.addColumn("age");
myTableModel.addColumn("address");
myJTable.setModel(myTableModel);
for (Person person : people) {
    myTableModel.addRow(person);
}

Each column will then use the Person object for the row to “get” the appropriate information to display.

+3
source share

Source: https://habr.com/ru/post/1796699/