Jump to Real's How-to Main page

Scroll a JTable to the last row

// in the your JTable 
//   jump to last row
rowCount =  table.getRowCount () - 1;
showCell(rowcount, 0);

//   jump to first row
showCell(0, 0);


public void showCell(int row, int column) {
    Rectangle rect = 
      getCellRect(row, column, true);
    scrollRectToVisible(rect);
    clearSelection();
    setRowSelectionInterval(row, row);
    getModel().fireTableDataChanged(); // notify the model
    }

If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]