void (Object value, boolean selected) { myText = ""; TextWithIcon textWithIcon = myTextWithIconProvider.apply(value); if (textWithIcon != null) { myText = textWithIcon.getText(); setIcon(textWithIcon.getIcon()); } else { myText = ""; } setText(myText); setBorder(BorderFactory.createEmptyBorder(0, 0, 0, UIUtil.getListCellHPadding())); setHorizontalTextPosition(SwingConstants.LEFT); setHorizontalAlignment(SwingConstants.RIGHT); // align icon to the right setBackground(selected ? UIUtil.getListSelectionBackground(true) : UIUtil.getListBackground()); setForeground(selected ? NamedColorUtil.getListSelectionForeground(true) : NamedColorUtil.getInactiveTextColor()); }