How to create a table model for JTable component?
Another way to create and configure a
JTable component is using a table model. A table model is more preferred to using array or vector as the data source for the table.
The simplest way to create a table model is by extending the
AbstractTableModel abstract class which implements the
TableModel interface. The
AbstractTableModel implements the standard behaviour of a table model. It implements almost all the methods of the
TableModel interface, except three methods.
These three methods are the
getValueAt(int rowIndex, int columnIndex) method, the
getRowCount() method and the
getColumnCount() method. The code below show you how to create a table model.