void (Graphics g, Rectangle bounds, boolean hasFocus) { ListCellRenderer<Object> renderer = comboBox.getRenderer(); Object value = comboBox.getSelectedItem(); Component c = renderer.getListCellRendererComponent(listBox, value, -1, false, false); c.setFont(comboBox.getFont()); c.setBackground(getBackgroundColor()); if (!Boolean.TRUE.equals(comboBox.getClientProperty(DISABLE_SETTING_FOREGROUND))) { if (hasFocus && !isPopupVisible(comboBox)) { c.setForeground(listBox.getForeground()); } else { c.setForeground(comboBox.isEnabled() ? comboBox.getForeground() : JBColor.namedColor("ComboBox.disabledForeground", comboBox.getForeground())); } } // paint selection in table-cell-editor mode correctly boolean changeOpaque = c instanceof JComponent && DarculaUIUtil.isTableCellEditor(comboBox) && c.isOpaque(); if (changeOpaque) { ((JComponent)c).setOpaque(false); } boolean shouldValidate = false; if (c instanceof JPanel) { shouldValidate = true; } Rectangle r = new Rectangle(bounds); Icon icon = null; Insets iPad = null; Border border = null; boolean enabled = true; if (c instanceof SimpleColoredComponent) { SimpleColoredComponent cc = (SimpleColoredComponent)c; iPad = cc.getIpad(); border = cc.getBorder(); enabled = cc.isEnabled(); cc.setBorder(JBUI.Borders.empty()); cc.setIpad(JBInsets.emptyInsets()); cc.setEnabled(comboBox.isEnabled()); icon = cc.getIcon(); if (!cc.isIconOnTheRight()) { cc.setIcon(OffsetIcon.getOriginalIcon(icon)); } } else if (c instanceof JLabel) { JLabel cc = (JLabel)c; border = cc.getBorder(); cc.setBorder(JBUI.Borders.empty()); icon = cc.getIcon(); cc.setIcon(OffsetIcon.getOriginalIcon(icon)); // the following trimMiddle approach is not good for smooth resizing: // the text jumps as more or less space becomes available. // a proper text layout algorithm on painting in DarculaLabelUI can fix that. String text = cc.getText(); int maxWidth = bounds.width - (padding == null || StartupUiUtil.isUnderDarcula() ? 0 : padding.right); if (StringUtil.isNotEmpty(text) && cc.getPreferredSize().width > maxWidth) { int max0 = ObjectUtils.binarySearch(7, text.length() - 1, idx -> { cc.setText(StringUtil.trimMiddle(text, idx)); return Integer.compare(cc.getPreferredSize().width, maxWidth); }); int max = max0 < 0 ? -max0 - 2 : max0; if (max > 7 && max < text.length()) { cc.setText(StringUtil.trimMiddle(text, max)); } } } else if (c instanceof JComponent) { JComponent cc = (JComponent)c; border = cc.getBorder(); cc.setBorder(JBUI.Borders.empty()); } currentValuePane.paintComponent(g, c, comboBox, r.x, r.y, r.width, r.height, shouldValidate); // return opaque for combobox popup items painting if (changeOpaque) { ((JComponent)c).setOpaque(true); } if (c instanceof SimpleColoredComponent) { SimpleColoredComponent cc = (SimpleColoredComponent)c; cc.setIpad(iPad); cc.setIcon(icon); cc.setBorder(border); cc.setEnabled(enabled); } else if (c instanceof JLabel) { JLabel cc = (JLabel)c; cc.setBorder(border); cc.setIcon(icon); } else if (c instanceof JComponent) { JComponent cc = (JComponent)c; cc.setBorder(border); } }