Component (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (ApplicationManager.getApplication().isHeadlessEnvironment() && value instanceof PsiElement) { putClientProperty(TARGET_PRESENTATION_KEY, computePresentation((PsiElement)value)); return this; } else if (myBackgroundRenderer != null && value instanceof PsiElement) { //noinspection unchecked return myBackgroundRenderer.getListCellRendererComponent(list, (PsiElement)value, index, isSelected, cellHasFocus); } removeAll(); myRightComponentWidth = 0; TextWithIcon itemLocation = getItemLocation(value); final JLabel locationComponent; final JPanel spacer; if (itemLocation == null) { locationComponent = null; spacer = null; } else { locationComponent = new JLabel(itemLocation.getText(), itemLocation.getIcon(), SwingConstants.RIGHT); locationComponent.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, UIUtil.getListCellHPadding())); locationComponent.setHorizontalTextPosition(SwingConstants.LEFT); locationComponent.setForeground(isSelected ? NamedColorUtil.getListSelectionForeground(true) : NamedColorUtil.getInactiveTextColor()); add(locationComponent, BorderLayout.EAST); spacer = new JPanel(); spacer.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); add(spacer, BorderLayout.CENTER); myRightComponentWidth = locationComponent.getPreferredSize().width; myRightComponentWidth += spacer.getPreferredSize().width; } ListCellRenderer<Object> leftRenderer = createLeftRenderer(list, value); Component result = leftRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); final Component leftCellRendererComponent = result; add(leftCellRendererComponent, LEFT); final Color bg = isSelected ? UIUtil.getListSelectionBackground(true) : leftCellRendererComponent.getBackground(); setBackground(bg); if (itemLocation != null) { locationComponent.setBackground(bg); spacer.setBackground(bg); } return this; }