void (@NotNull JList<Configuration> list, boolean up) { final MyListModel model = (MyListModel)list.getModel(); final List<Configuration> values = list.getSelectedValuesList(); final Comparator<Configuration> c = Comparator.comparingInt(Configuration::getOrder); values.sort(up ? c : c.reversed()); final int[] indices = new int[values.size()]; for (int i = 0, size = values.size(); i < size; i++) { final Configuration value = values.get(i); final int order = value.getOrder(); model.swap(order, order + (up ? -1 : +1)); indices[i] = value.getOrder(); } myMainConfiguration = moveMetaData(myMainConfiguration, myConfigurations.get(0)); list.setSelectedIndices(indices); list.scrollRectToVisible(list.getCellBounds(indices[0], indices[indices.length - 1])); model.fireContentsChanged(list); saveChangesToProfile(list); }