package pesquisa; import javax.swing.table.*; import javax.swing.event.*; class PresentationTableModel extends AbstractTableModel { private int numcols, numrows; // How many rows and columns in the table String[][] contents; String[] headerFieldNames; PresentationTableModel(String[][] contents, String[] headerFieldNames, int numrows, int numcols) { this.contents = contents; this.headerFieldNames = headerFieldNames; this.numrows = numrows; // How many rows? this.numcols = numcols; // How many columns? } public int getColumnCount() { return numcols; } public int getRowCount() { return numrows; } public String getColumnName(int columnIndex) { return headerFieldNames[columnIndex]; } public Object getValueAt(int row, int col) { try { return contents[row][col]; } catch(Exception exception) { exception.printStackTrace(); } return null; } public Class getColumnClass(int c) { return String.class; } // Table isn't editable public boolean isCellEditable(int row, int column) { return false; } // Since its not editable, we don't need to implement these methods public void setValueAt(Object value, int row, int column) { } public void addTableModelListener(TableModelListener l) { } public void removeTableModelListener(TableModelListener l) { } }