void (List<? extends SearchResult> searchResults) { if (searchResults == null || searchResults.isEmpty()) { return; } int oldSelectedIndex = myShowingResultsList.getSelectedIndex(); ListElementWrapper oldSelectedValue = myShowingResultsList.getSelectedValue(); myResultsListModel.addAll(0, searchResults); if (myShowingResultsList.getSelectedValue() != oldSelectedValue) { for (int i = -1; i <= 1; i++) { int probablySelectedIndex = oldSelectedIndex + searchResults.size() + i; if (myShowingListModel.getElementAt(probablySelectedIndex) == oldSelectedValue) { myShowingResultsList.setSelectedIndex(probablySelectedIndex); break; } } } // compensating for shift of viewport Rectangle cellBounds = myShowingResultsList.getCellBounds(0, 0); int cellHeight = cellBounds.height; int additionalHeight = cellHeight * searchResults.size(); Rectangle visibleRect = myShowingResultsList.getVisibleRect(); visibleRect.y += additionalHeight; myShowingResultsList.scrollRectToVisible(visibleRect); }