In the preceding example, the table data were stored in a two-dimensional array. However, you should generally not use that strategy in your own code. If you find yourself dumping data into an array to display it as a table, you should instead consider implementing your own table model.
Table models are particularly simple to implement because you can take advantage of the
AbstractTableModel class that implements most of the required methods. You only need to supply three methods:
public int getRowCount(); public int getColumnCount(); public Object getValueAt(int row, int column);
There are many ways of implementing the
getValueAt method. For example, if you want to display the contents of a
RowSet that contains the result ...