Component () { if (0 == myTree.getY()) { return null; // separator is not needed without scrolling } if (myHeader == null) { myHeader = new JLabel(); myHeader.setForeground(UIUtil.getTreeForeground()); myHeader.setIconTextGap(JBUIScale.scale(ICON_GAP)); myHeader.setBorder(JBUI.Borders.empty(2, 10 + getLeftMargin(0), 0, 0)); } myHeader.setFont(myTree.getFont()); myHeader.setIcon(getIcon(null, false)); int height = myHeader.getPreferredSize().height; String group = findGroupNameAt(0, height + 3); if (group == null || !group.equals(findGroupNameAt(0, 0))) { return null; // do not show separator over another group } myHeader.setText(group); return myHeader; }