I have data from a database loaded into a JTable through a custom table model. I want to have a column (should be the first column) which simply shows the display row number (i.e. it is not tied to any data (or sorting) but is simply the row number on the screen starting at 1). These “row headers” should be grayed out like the row headers.
Any idea how to do this?
Thanks
What TableModel are you using?
You can override
public Object getValueAt(int row, int column)to do this in your TableModel.I.e.
If that isn’t working when you sort your JTable, then another solution is to implement it in a custom
TableCellRendererand override: