hi I have this jtable which I want to have its auto increment row header for the user to identify how many data does the table returned. I am actually getting the table model from result set and the data is not fixed. It vary depends on the search of the user.
Here's my table model code:
public void retrieveMember() throws SQLException {
mDao.dbConnect();
try {
if(mDao.con!=null)
{
mDao.ps = mDao.con.prepareStatement(this.getSql());
mDao.rs = mDao.ps.executeQuery();
this.tblGender.setModel(DbUtils.resultSetToTableModel(mDao.rs));
int[] columnsWidth = { 100, 150, 150, 300, 50, 60, 100, 100, 125,65};
int i = 0;
for (int width : columnsWidth) {
TableColumn column =this.tblGender.getColumnModel().getColumn(i++);
column.setMinWidth(width);
column.setMaxWidth(width);
column.setPreferredWidth(width);
}
} else
{
System.out.println("Con is null");
}
} catch (SQLException ex) {
ex.printStackTrace();
throw ex;
}
}
Can anyone help me to put an auto increment row header? Something that will display how many data does my table returning.
-------------------------
Name| Age | Gender
-------------------------
1| Nely| 16 |Female
2| Amy | 18 |Female
thank you in advance.