Component (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component rendererComponent = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //noinspection unchecked IntroduceTarget expr = (T)value; String text = expr.render(); int firstNewLinePos = text.indexOf('\n'); String trimmedText = text.substring(0, firstNewLinePos != -1 ? firstNewLinePos : Math.min(100, text.length())); if (trimmedText.length() != text.length()) trimmedText += " ..."; setText(trimmedText); return rendererComponent; }