void () { ColoredListCellRenderer<CompletionItem> itemRenderer = new ColoredListCellRenderer<>() { @Override protected void customizeCellRenderer(@NotNull JList<? extends CompletionItem> list, @Nullable CompletionItem value, int index, boolean selected, boolean hasFocus) { if (!selected) { setBackground(UIUtil.getListBackground()); } String text = value == null ? "" : value.displayText; FList<TextRange> ranges = currentMatcher == null ? FList.emptyList() : currentMatcher.matchingFragments(text); SpeedSearchUtil.appendColoredFragments(this, text, ranges, SimpleTextAttributes.REGULAR_ATTRIBUTES, MATCHED); setIcon(value == null ? null : value.icon); } }; myTemplatesList.setCellRenderer((list, value, index, isSelected, cellHasFocus) -> { Component item = itemRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); JPanel wrapperPanel = new JPanel(new BorderLayout()); wrapperPanel.setBackground(UIUtil.getListBackground()); if (index == 0 || value.contributor != list.getModel().getElementAt(index - 1).contributor) { SeparatorWithText separator = new SeparatorWithText() { @Override protected void paintLinePart(Graphics g, int xMin, int xMax, int hGap, int y) { } }; separator.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); int vGap = UIUtil.DEFAULT_VGAP / 2; separator.setBorder(BorderFactory.createEmptyBorder(vGap * (index == 0 ? 1 : 2), 0, vGap, 0)); separator.setCaption(value.contributor.getDescription()); separator.setCaptionCentered(false); wrapperPanel.add(separator, BorderLayout.NORTH); } wrapperPanel.add(item, BorderLayout.CENTER); return wrapperPanel; }); }