Advertisement
Guest User

ProgramTableModel

a guest
Apr 12th, 2012
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. import java.util.List;
  2.  
  3. import javax.swing.table.AbstractTableModel;
  4.  
  5.  
  6. public class ProgramTableModel extends AbstractTableModel
  7. {
  8.     private List<Program> schedule;
  9.    
  10.     public ProgramTableModel(List<Program> schedule)
  11.     {
  12.         this.schedule= schedule;
  13.     }
  14.    
  15.    
  16.     public int getColumnCount()
  17.     {
  18.         return 7;
  19.     }
  20.  
  21.    
  22.     public int getRowCount()
  23.     {
  24.         return schedule.size();
  25.     }
  26.  
  27.    
  28.     public Object getValueAt(int rowIndex, int columnIndex)
  29.     {
  30.         Program sData = schedule.get(rowIndex);
  31.        
  32.         switch (columnIndex)
  33.         {
  34.         case 0: return sData.getTitle();
  35.         case 1: return sData.getDuration();
  36.                 case 2: return sData.getCategory();
  37.                 case 3: return sData.getActor();
  38.                 case 4: return sData.getDirector();
  39.                 case 5: return sData.getSynopsis();
  40.                 case 6: return sData.getRentable();
  41.                 default: return "Not Available.";
  42.         }
  43.        
  44.     }
  45.        
  46.              
  47.    
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement