You need to add a ListSelectionListener, so you can react on selection changes. This of looks like this:


JList<String> list1 = new JList<>();
list1.addListSelectionListener(new...