package us.deans.zinctest; import javax.swing.table.AbstractTableModel; import us.deans.zinc.ZnDemandList; import us.deans.zinc.ZnDemandRecord; /** Swing table view for summary demand view */ public class ZnTableModel_002 extends AbstractTableModel { private static final long serialVersionUID = 1L; private ZnDemandList demandList; private String[] headings = new String[] {"location","demand","count"}; private int rowCount; private int colCount; public ZnTableModel_002(ZnDemandList demandList){ this.demandList = demandList; this.colCount = 3; this.rowCount = demandList.size(); } public int getColumnCount(){ return this.colCount; } public int getRowCount(){ return this.rowCount; } public Object getValueAt(int row, int column){ if(row>=demandList.size()){ return null; } ZnDemandRecord demand = demandList.get(row); if(column==0){ return demand.getLocation(); } if(column==1){ return demand.getKeyTerm(); } if(column==2){ return demand.getCount(); } return null; } public String getColumnName(int column){ return this.headings[column]; } }