Component ( final JList list, LookupElement item, int index, boolean isSelected, boolean hasFocus) { boolean nonFocusedSelection = isSelected && myLookup.getLookupFocusDegree() == LookupFocusDegree.SEMI_FOCUSED; if (!myLookup.isFocused()) { isSelected = false; } myIsSelected = isSelected; myPanel.setSelectionColor(nonFocusedSelection ? SELECTED_NON_FOCUSED_BACKGROUND_COLOR : isSelected ? SELECTED_BACKGROUND_COLOR : null); int allowedWidth = list.getWidth() - calcSpacing(myNameComponent, myEmptyIcon) - calcSpacing(myTailComponent, null) - calcSpacing(myTypeLabel, null); LookupElementPresentation presentation = myAsyncRendering.getLastComputed(item); for (ItemPresentationCustomizer customizer : myCustomizers) { presentation = customizer.customizePresentation(item, presentation); } if (presentation.getIcon() != null) { setIconInsets(myNameComponent); } myNameComponent.clear(); Color itemColor = presentation.getItemTextForeground(); allowedWidth -= setItemTextLabel(item, itemColor, presentation, allowedWidth); myTailComponent.setFont(ObjectUtils.notNull(getCustomFont(item, false, CUSTOM_TAIL_FONT), myNormalFont)); myTypeLabel.setFont(ObjectUtils.notNull(getCustomFont(item, false, CUSTOM_TYPE_FONT), myNormalFont)); myNameComponent.setIcon(augmentIcon(myLookup.getTopLevelEditor(), presentation.getIcon(), myEmptyIcon)); final Color grayedForeground = getGrayedForeground(isSelected); myTypeLabel.clear(); if (allowedWidth > 0) { allowedWidth -= setTypeTextLabel(item, grayedForeground, presentation, isSelected ? getMaxWidth() : allowedWidth, isSelected, nonFocusedSelection, getRealFontMetrics(item, false, CUSTOM_TYPE_FONT)); } myTailComponent.clear(); if (isSelected || allowedWidth >= 0) { setTailTextLabel(item, isSelected, presentation, grayedForeground, isSelected ? getMaxWidth() : allowedWidth, nonFocusedSelection, getRealFontMetrics(item, false, CUSTOM_TAIL_FONT)); } if (mySelected.containsKey(index)) { if (!isSelected && mySelected.get(index)) { myPanel.setUpdateExtender(true); } } mySelected.put(index, isSelected); final double w = myNameComponent.getPreferredSize().getWidth() + myTailComponent.getPreferredSize().getWidth() + myTypeLabel.getPreferredSize().getWidth(); boolean useBoxLayout = isSelected && w > list.getWidth() && ((JBList<?>)list).getExpandableItemsHandler().isEnabled(); if (useBoxLayout != myPanel.getLayout() instanceof BoxLayout) { myPanel.removeAll(); if (useBoxLayout) { myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.X_AXIS)); myPanel.add(myNameComponent); myPanel.add(myTailComponent); myPanel.add(myTypeLabel); } else { myPanel.setLayout(new BorderLayout()); myPanel.add(myNameComponent, BorderLayout.WEST); myPanel.add(myTailComponent, BorderLayout.CENTER); myPanel.add(myTypeLabel, BorderLayout.EAST); } } AccessibleContextUtil.setCombinedName(myPanel, myNameComponent, "", myTailComponent, " - ", myTypeLabel); AccessibleContextUtil.setCombinedDescription(myPanel, myNameComponent, "", myTailComponent, " - ", myTypeLabel); return myPanel; }