Friday, September 14, 2007

Java: highlight and show a particular row/cell in JTable inside JScrollPane

1. When we want to highlight one particular row in a JTable, we could call:
getTable().setRowSelectionInterval(i, i);


2. When we want to show a particular row/cell in a JTable inside a JScrollPane, we could call,

getTable().scrollRectToVisible(getTable().getCellRect(row, 0, true));

But it doesn't work so well if we overwrite the DefaultTableCellRenderer.

No comments: