After getting data from my database, I have to show this in a JTable.
In my design I can specify how much rows the JTable should have.
But when my array of data is longer then the specified rows, I get an exception. This is because my table is too small for all the data I want to add in it.
How can I dynamically add rows to my table according to the size of the array?
TableModel tmPerson = taTablePerson.getModel();
for (int index = 0; index < arrpBag.length; index++)
{
dtmPerson.setValueAt(arrpBag[index].getId(), index, 0);
dtmPerson.setValueAt(arrpBag[index].getRijksregisternummer(), index, 1);
dtmPerson.setValueAt(arrpBag[index].getNaam(), index, 2);
dtmPerson.setValueAt(arrpBag[index].getVoornaam(), index, 3);
dtmPerson.setValueAt(arrpBag[index].getStraat(), index, 4);
dtmPerson.setValueAt(arrpBag[index].getNummer(), index, 5);
dtmPerson.setValueAt(arrpBag[index].getBus(), index, 6);
dtmPerson.setValueAt(arrpBag[index].getPostnummer(), index, 7);
dtmPerson.setValueAt(arrpBag[index].getGemeente(), index, 8);
dtmPerson.setValueAt(arrpBag[index].getTelefoonnummer(), index, 9);
}
//Create extra rows when not enough
if (taTabelPersonen.getRowCount() < arrpBag.length)
{
//What code should be placed here?
}
taTabelPersonen.setModel(dtmPersoon);