I realized a JTable with a custom AbstractTableModel
for implementing paging.
I wanna show 5 item per page, but I\'ve a problem: if I have N item to show (with N wh
Just pin the the value to its acceptable maximum:
realRow = Math.min(realRow, getRowCount());
Addendum: In the example cited, implement getValueAt()
as follows:
// Work only on the visible part of the table.
public Object getValueAt(int row, int col) {
int realRow = row + (pageOffset * pageSize);
if (realRow < data.length) {
return data[realRow].getValueAt(col);
} else {
return null;
}
}
Also consider BasicArrowButton.
Make sure your model's getRowCount method is inline with what you want it to do. The getRowCount method should return an acceptable number for your table, so that it doesn't call getValueAt for any rows that don't exist. So, if you have no row 14, your row count shouldn't be that high.
I think that not easy job, I suggessting to look at aephyr's code, maybe more easies way is implementing this code, but for real effect you have to lock JScrollBars
, swith to NEVER