static void selectRow(final JTable table, final int i) { if (table != null) swing { if (i >= 0 && i < table.getRowCount()) { table.setRowSelectionInterval(i, i); scrollRowToVisible(table, i); } else table.clearSelection(); } } static void selectRow(final JList list, final int i) { if (list != null) swing { if (i >= 0 && i < listRowCount(list)) list.setSelectedIndex(i); else list.clearSelection(); } }