package gui; import java.util.*; import javax.swing.*; import javax.swing.table.*; public class InfoTableModel extends AbstractTableModel { public InfoTableModel(List components, int numRows, int numCols) { this.numRows = numRows; this.numCols = numCols; data = new Object[numRows][numCols]; for(int i = 0; i < numRows; i++) { for(int j = 0; j < numCols; j++) { int pos = i*numCols + j; data[i][j] = components.get(pos); } } } public int getRowCount() { return numRows; } public int getColumnCount() { return numCols; } public Object getValueAt(int row, int column) { return data[row][column]; } public void setValueAt(Object value, int row, int column) { data[row][column] = (JComponent) value; } public Class getColumnClass(int c) { return JComponent.class; } public String getColumnName(int c) { return c + ""; } private int numRows; private int numCols; private Object data[][]; }