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.Collection; 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.Serie; import streaming.service.SerieService; /** * * @author admin */ @Component public class SerieTableModel extends DefaultTableModel { private List<Serie> serie; private int nbSerie = 0; @Autowired private SerieService serieService; public List<Serie> getSerie() { return serie; } public void setSerie(List<Serie> serie) { this.serie = serie; nbSerie = serie.size(); } public SerieTableModel() { setColumnIdentifiers(new String[] { "ID", "Titre", "Synopsis", "Pays" }); } public void rafraichir() { serie = serieService.rechercherTout(); nbSerie = serie.size(); } @Override public int getRowCount() { return nbSerie; } @Override public Object getValueAt(int row, int column) { Serie serie = this.serie.get(row); if (column == 0) { return serie.getId(); } if (column == 1) { return serie.getTitre(); } if (column == 2) { return serie.getSynopsis(); } if (column == 3) { return serie.getPays(); } return ("FAIL"); } }