I have the question of how to obtain the data of a cell in the last row of a jtable, I used:
jTable1.getValueAt(1,0).toString();
but only shows me a specific data, I would like to obtain the last value no matter how many data the jtable has.
I have the question of how to obtain the data of a cell in the last row of a jtable, I used:
jTable1.getValueAt(1,0).toString();
but only shows me a specific data, I would like to obtain the last value no matter how many data the jtable has.
There are two ways:
Through the model that handles the data:
TableModel modelo = jtable1.getModel();
int indiceUltimaFila = modelo.getRowCount() - 1;
Object valor = modelo.getValueAt(indiceUltimaFila, 0);
Through the table directly that makes queries to your underlying model:
int indiceUltimaFila = jtable1.getRowCount() - 1;
Object valor = jtable1.getValueAt(indiceUltimaFila, 0);
The difference between one and another is what the user sees in the interface (second option) (for example, if he reordered the columns). vs how they are stored internally (first option) the results may be a little different from what is expected. The above can be seen here