void (@NotNull JList c, @NotNull ListSelectionModel selectionModel, int size, int direction, @NotNull Runnable handleFocusParent, boolean isCycleScrolling) { if (size == 0) return; int index = selectionModel.getMaxSelectionIndex(); int indexToSelect = index + direction; if ((indexToSelect == -2 || indexToSelect >= size) && !isCycleScrolling) { return; } if (indexToSelect == -2) { indexToSelect = size - 1; } else if (indexToSelect == -1 || indexToSelect >= size) { handleFocusParent.run(); return; } ScrollingUtil.ensureIndexIsVisible(c, indexToSelect, -1); selectionModel.setSelectionInterval(indexToSelect, indexToSelect); }