ListElementWrapper (int index) { if (btnSearchBackwardWrapper.isEnabled) { if (index == 0) { return btnSearchBackwardWrapper; } if (index == mySearchResultsListModel.getSize() + 1) { return btnSearchForwardWrapper; } return new SearchResultWrapper(mySearchResultsListModel.getElementAt(index - 1)); } else { if (index == mySearchResultsListModel.getSize()) { return btnSearchForwardWrapper; } return new SearchResultWrapper(mySearchResultsListModel.getElementAt(index)); } }