void (JList<?> list) { int visible = getVisibleRowCount(list); ListSelectionModel selectionModel = list.getSelectionModel(); if (visible <= 0) { moveHome(list); return; } int size = list.getModel().getSize(); int decrement = visible - 1; int index = Math.max(list.getSelectedIndex() - decrement, 0); int top = list.getFirstVisibleIndex() - decrement; if (top < 0) { top = 0; } int bottom = top + visible - 1; if (bottom >= size) { bottom = size - 1; } //list.clearSelection(); Rectangle cellBounds = list.getCellBounds(top, bottom); if (cellBounds == null) { moveHome(list); return; } list.scrollRectToVisible(cellBounds); selectionModel.setSelectionInterval(index,index); list.ensureIndexIsVisible(index); }