you did a mistake there in initJList() function, you already have passed value of listModel before itself, and again you have passed this value here in this function , so commenting this line will solve the problem. the modified function will look like this here:
private void initJList() {
selectedItems.setVisibleRowCount(8);
selectedItems.setFixedCellWidth(300);
selectedItems.setFixedCellHeight(40);
selectedItems.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
selectedItems.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//selectedItems = new JList<String>(listModel);
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
}
Otherwise :
Declaring the JList like this
public JList<String> selectedItems;
and keeping the function as it is will run fine.