@Override protected void customizeCellRenderer( JList list, Object value, int index, boolean selected, boolean hasFocus) { setIcon(myListEntryIcon); if (myUseIdeaEditor) { int max = list.getModel().getSize(); String indexString = String.valueOf(index + 1); int count = String.valueOf(max).length() - indexString.length(); char[] spaces = new char[count]; Arrays.fill(spaces, ' '); String prefix = indexString + new String(spaces) + " "; append(prefix, SimpleTextAttributes.GRAYED_ATTRIBUTES); } else if (UIUtil.isUnderGTKLookAndFeel()) { // Fix GTK background Color background = selected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground(); UIUtil.changeBackGround(this, background); } String text = ((Item) value).shortText; FontMetrics metrics = list.getFontMetrics(list.getFont()); int charWidth = metrics.charWidth('m'); int maxLength = list.getParent().getParent().getWidth() * 3 / charWidth / 2; text = StringUtil.first(text, maxLength, true); // do not paint long strings append(text, SimpleTextAttributes.REGULAR_ATTRIBUTES); }