void (boolean fwd) { int index = table.getSelectionModel().getLeadSelectionIndex(); int count = table.getRowCount(); int newIdx = (count + index + (fwd ? 1 : -1)) % count; table.getSelectionModel().setSelectionInterval(newIdx, newIdx); }