void (ListSelectionEvent e) { ListSelectionModel selectionModel = (ListSelectionModel)e.getSource(); int lastIndex = e.getLastIndex(); int firstIndex = e.getFirstIndex(); DirDiffElementImpl last = myModel.getElementAt(lastIndex); DirDiffElementImpl first = myModel.getElementAt(firstIndex); if (last == null || first == null) { update(false); return; } if (last.isSeparator() && selectionModel.isSelectedIndex(lastIndex)) { int ind = lastIndex + ((lastIndex < firstIndex) ? 1 : -1); selectionModel.addSelectionInterval(ind, ind); } if (first.isSeparator() && selectionModel.isSelectedIndex(firstIndex)) { int ind = firstIndex + ((firstIndex < lastIndex) ? 1 : -1); selectionModel.addSelectionInterval(ind, ind); } else { update(false); } myDiffWindow.setTitle(myModel.getTitle()); }