void () { ArrayList<String> selected = new ArrayList<>(); for (int index : getSelectedIndices()) { E value = getModel().getElementAt(index); String text = itemToText(index, value); if (text != null) selected.add(text); } if (selected.size() > 0) { String text = StringUtil.join(selected, "\n"); CopyPasteManager.getInstance().setContents(new StringSelection(text)); } }