Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package streaming.gui; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.Persistence; import javax.swing.table.DefaultTableModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import streaming.entity.Film; import streaming.entity.Genre; import streaming.service.GenreService; /** * * @author ajc */ @Component public class GenreTableModelList extends DefaultTableModel { @Autowired private GenreService genreService; private List<Genre> genre = null; public void setGenre(List<Genre> genre) { this.genre = genre; } private int taille = 0; public List<Genre> getGenre() { return genre; } public GenreTableModelList() { setColumnIdentifiers(new String[] { "NOM" });//,"GENRE","PAYS"}); // genre = (List<Genre>) genreService.rechercherTout(); // taille = genre.size(); } public GenreTableModelList(List l) { setColumnIdentifiers(new String[] { "NOM" });//,"GENRE","PAYS"}); genre = l; taille = genre.size(); } @Override public Object getValueAt(int row, int column) { Genre g = genre.get(row); if (column == 0) { return g.getNom(); } return " -- ERREUR -- "; } @Override public int getRowCount() { return taille; } }