void (ListSelectionEvent e) { if (e.getValueIsAdjusting() || ourInstance.isRunningOn(myTable) || locked()) return; int row = getLeadSelectionIndexIfSelectionIsNotEmpty(getRowSelectionModel()); int col = getLeadSelectionIndexIfSelectionIsNotEmpty(getColumnSelectionModel()); boolean validRow = (row >= 0 || myTable.getRowCount() == 0) && row < myTable.getRowCount(); boolean validCol = (col >= 0 || myTable.getColumnCount() == 0) && col < myTable.getColumnCount(); if (validRow && validCol) myTable.scrollRectToVisible(myTable.getCellRect(row, col, false)); }