import javax.swing.table.AbstractTableModel;


public class MyTableModel extends AbstractTableModel {
	
	String[][] records;
	String[] colNames;
	
	public MyTableModel(String[][] records, String[] colNames) {
		this.records = records;
		this.colNames = colNames;
	}
	
	@Override
	public String getColumnName(int column) {
		return colNames[column];
	}

	@Override
	public int getColumnCount() {
            return colNames.length;
	}

	@Override
	public int getRowCount() {
		return 20;
	}

	@Override
	public Object getValueAt(int row, int col) {
		return records[row][col];
	}

	@Override
	public boolean isCellEditable(int row, int col) {
		if (col == 1)
			return true;
		else
			return false;
	}
	
	// As we allow the value in a cell to be changed, we must override this method.
	@Override
	public void setValueAt(Object value, int row, int col) {
		records[row][col] = (String)value;
		
		// Notify JTable that the value of the cell has changed.
		fireTableCellUpdated(row, col);
	}
}
