JTable has a Table Model ... create a class that extends DefaultTableModel, and mount your model .. modify the template, then make table.setModel (yourModel)
Example:
for a class with these attributes
class Cliente{
Integer id;
String nome;
//getters and setters
}
You can do the following:
class ClienteTableModel extends DefaultTableModel{
public ClienteTableModel(){
this.addColumn("ID");
this.addColumn("NOME");
}
public ClienteTableModel(List<Cliente> listClientes){
this();
for(Cliente c: listClientes){
this.addRow(new String[]{c.getId(),c.getNome()});
}
}
}
Then, in your view, you do this:
List<Cliente> listClientes = buscaClientes();
ClienteTableModel model = new ClienteTableModel(listClientes);
table.setModel(model);